Jump to content

Get value from an html input


nanfilho

Recommended Posts

In your case:

1.

...
<button type="button" class="btn btn-primary" onclick="ajaxRequest(MainForm.LbHTML,'button',['val='+document.getElementById('exampleInputEmail1').value])">Submit</button>

...

2.

procedure TMainForm.LbHTMLAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='button' then
  Begin
    //UniSession.AddJS('MainForm.UniEdit1.setValue(document.getElementById("exampleInputEmail1").value);');
    UniEdit1.Text := Params.Values['val'];
    ShowMessage(UniEdit1.Text);
  End;
end;

 

Link to comment
Share on other sites

Thank you, it worked perfect!
in case, if I want to get more than one value, what is the correct form? I tried

  <button type="button" class="btn btn-primary" onclick="ajaxRequest(MainForm.LbHTML,'button',['val1='+document.getElementById('exampleInputEmail1').value,
                                                                                               'val2='+document.getElementById('exampleInputPassword1').value])">Submit</button>

but it did not work...

Link to comment
Share on other sites

7 hours ago, Sherzod said:

What code is in the server side?

What is your problem?

the problem is that I need to get more than one value, such as email and login password, but I could not return.

procedure TMainForm.LbHTMLAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='button' then
  Begin
      ShowMessage('Email '+ Params.Values['val1']+#13+
                  'Password '+ Params.Values['val2']);
  End;
end;

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...