Jump to content

ajaxrequest in htmlframe


jahlxx

Recommended Posts

Hi.

I put a button in a htmlframe.

How can I set the click event in that button?

I've tried some samples found in the forumns, with no success.

Tried with this:

          <button type="submit" onclick="ajaxRequest(UniHTMLFrame1, '_enviar', [ 'param0=A', 'param1=B' ]);">Enviar formulario</button>

And this:

          <input type="button" value="Test"  class="button"  onclick="ajaxRequest(UniHTMLFrame1, '_enviar', [ 'param0=A', 'param1=B' ]);"/>      

Can someone give some help to me?

Thanks.

Link to comment
Share on other sites

Ok.

I don't understand this part:

onclick="window.parent.ajaxRequest(window.parent.Ext.get(window.parent.document.getElementById('O1B_id')).component,'SET_OLD_DIAG_DCID', {});"

 

My HTMLFrame' name is called UniHTMLFrame1. Can you please give me a clear sample with that?

Thanks.

 

Link to comment
Share on other sites

30 minutes ago, jahlxx said:

HTMLFrame.zip 16.25 kB · 0 downloads

Well, specifically for your case, you can do this:

1. 

<p><button onclick="window.parent.ajaxRequest(window.MainForm.UniHTMLFrame1,'_saludar', []);">Test 3</button></p>

2. 

procedure TMainForm.UniHTMLFrame1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_saludar' then
     showmessage('hi!');
end;

 

Link to comment
Share on other sites

19 minutes ago, jahlxx said:

It works, but doesn't work in my project, and I can't find the reason.

Works in test project, not in "real" project.

Any idea? Any config option?

Also, please analyze this demo:

\FMSoft\Framework\uniGUI\Demos\Desktop\ClientEvents-HtmlToAjax

See ClientEvents -> UniEvents -> 

And analyze HTML property...

Link to comment
Share on other sites

Ok.

Thanks friend. It works.

Now, I'm trying to return the value of a textarea, and taking as reference ths post in forums:

I try this, but don't raises the ajaxevent:

onclick="window.parent.ajaxRequest(window.ftemas46.UniHTMLFrame1,'_enviar',['val1=' + document.getElementById('solucion').value]);"

'solucion' is a textarea in the html code.

Any idea? How can I return the value of the textarea?

Thanks.

Link to comment
Share on other sites

I think yes.

I have this in html:

<p><textarea name="solucion" rows="5" style="font-size: 1.1em; min-width: 100%;"></textarea></p>
<p><button onclick="window.parent.ajaxRequest(window.ftemas46.UniHTMLFrame1,'_enviar',['val1=' + document.getElementById('solucion').value]);">Enviar</button></p>
                    

and in ajaxevent of the htmlframe:

  if EventName = '_enviar' then
     showmessage('Solucion: ' + Params.Values['val1']);

 

But nothing happens.

 

????

 

Link to comment
Share on other sites

Hi.

Is ajaxrequest the only way to access to the value of a field in a htmlframe?

I'm considering some options, to take the best way for me. With ajax, I got it, but is possible to access the value from the "unigui side"?

For example. I have a textarea field in a htmlframe. The user type some text. I have a tunibutton in the unigui form. Is possible to have something similar to this in he onclick event of the button?

procedure Tfformulario.UniToolButton6Click(Sender: TObject);
begin
  showmessage(textarea.name.value);  // this is not correct, is only for clarify
end;

 

Thanks.

 

 

 

Link to comment
Share on other sites

12 minutes ago, jahlxx said:

How?

Simple case.

1. HTML

<!DOCTYPE html>

<html>

<body>
  <p><textarea onblur="window.parent.ajaxRequest(window.MainForm.UniHTMLFrame1,'_saludar', ['val='+this.value]);"></textarea></p>                 
</body>

</html>

2. 

procedure TMainForm.UniHTMLFrame1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_saludar' then
    (Sender as TUniHTMLFrame).CustomAttribs.Values['val'] := Params.Values['val']
end;

3. Usage:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  ShowMessage(UniHTMLFrame1.CustomAttribs.Values['val'])
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...