Link to home
Create AccountLog in
Avatar of olisaac
olisaac

asked on

ISAPI (button on HTML Page)

I'm creating an ISAPI application

how can I receive the fact that a user has clicked(submit) on a butoon in a HTML PAGE ?

I've to use the TWebActionItem ?

Where I've to put my code to execute the function related to this button ?

Thanks a lot

Olivier
Avatar of Epsylon
Epsylon

The following html-code could be a part on a page:

<FORM method=post action="cgi-bin/button.dll/click">
<input type=submit value=Search>
......


When the button is pressed, the ISAPI gets an action '/click'

In you ISAPI app double-click on the WebModule window. In the appearing window add a new actionitem. Set its PathInfo property to '/click'. Now write the OnAction event.

Eps.
Listening...
Hi Olivier,

1. Receiving the fact of button click:
I've always named my buttons in HTML code like:
<INPUT TYPE=submit NAME="LoginBtn" VALUE="Login">

The Delphi code is:
....
if (Request.ContentFields.Values['LoginBtn'] <> '') then begin
  .....
end;
....
which means that exactly login button has been clicked. (if I have more btns on the page)

2. Using WebActionItems:
  It's recommended to have at least one Action Item with no PathInfo property (empty) and Default = True. That way all requests will be handled here.
  You can use BeforeDispatch event of the WebDispatcher also.
  For more complicated jobs you can use PathInfo after the name of your dll in different html pages to react with different Action Items depending on the PathInfo of the request. {see Epsylon's comment}

3. Where to put code:
  It depends on the answer of the question 2. If you are using different Action Items the code can be in the code of the proper item, in the default item, ih the before or after dispatch events.

Regards, Geo
Avatar of olisaac

ASKER

Adjusted points from 50 to 75
Avatar of olisaac

ASKER

Hi,

Thanks, it works.

But I have another question (reason for the increase of the points).

When I push the button, in my Delphi code I want to make integrity tests on text box (in the html page too (TITRE In my sample code)).
If the data is not good in this text box. I would that the page HTML don't change to permit to the user to correct his mistake

I've to change the value of the handle in the beforedispatch or afterdispatch function

I don't know if my question is so clear...

Olivier

Sample of my code :

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  if (Request.ContentFields.Values['ADD'] <> '') then
    begin

    if length(Titre1) > 50 then
      begin
        MessageDlg('TITRE NOT CORRECT', mtInformation, [mbOk], 0);
        exit;
      end;
end;
Avatar of olisaac

ASKER

Hi geobul, if you answer my second question, the points are for you...
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of olisaac

ASKER

I will have some other questions for you in a few days...
I will be happy to help !