RTC Forums

Subscription => Support => Topic started by: clockon on April 30, 2014, 01:16:07 AM



Title: get button pressed from a submit
Post by: clockon on April 30, 2014, 01:16:07 AM
hi

Is there a way I can tell which button was pressed from a page submit?


Title: Re: get button pressed from a submit
Post by: D.Tkalcec (RTC) on May 01, 2014, 10:01:28 PM
You can use the value tag in HTML to send different values for each SUBMIT button on a Form.
You can read the value of each variable received POST data, the same way you can read edit field values.
Here is an example of a "OnDataReceived" event (modify the QuickStart/BrowserUpload example) ...

with TRtcDataServer(Sender) do
    begin
    if Request.Method='GET' then
      begin
      Write('<html><body><form enctype="multipart/form-data" method="post">');
      Write('Are you sure?');
      Write('<input type="answer" value="Yes">');
      Write('<input type="answer" value="No">');
      Write('<input type="answer" value="Cancel">');
      Write('</form></body></html>');
      end
    else
      begin
      Request.Params.AddText(Read);
      if Request.Complete then
        begin
        if Request.Params['answer']='Yes' then
          Write('You clicked YES')
        else if Request.Params['answer']='No' then
          Write('You clicked NO')
        else
          Write('You clicked Cancel?');
        end;
      end;
    end;


Best Regards,
Danijel Tkalcec


Title: Re: get button pressed from a submit
Post by: clockon on May 02, 2014, 01:11:10 AM
yep so i have to store the result of the button, thats what i thought from the dataReceived output. thanks :)