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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...