RTC Forums
November 01, 2024, 03:22:36 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: get button pressed from a submit  (Read 4522 times)
clockon
RTC Expired
*
Posts: 22


« on: April 30, 2014, 01:16:07 AM »

hi

Is there a way I can tell which button was pressed from a page submit?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 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
Logged
clockon
RTC Expired
*
Posts: 22


« Reply #2 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 Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.022 seconds with 17 queries.