jahlxx Posted March 30, 2022 Share Posted March 30, 2022 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 30, 2022 Share Posted March 30, 2022 Hello, 3 minutes ago, jahlxx said: ajaxRequest For example: Quote Link to comment Share on other sites More sharing options...
jahlxx Posted March 30, 2022 Author Share Posted March 30, 2022 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 30, 2022 Share Posted March 30, 2022 Okay, Could you please make a simple testcase? Quote Link to comment Share on other sites More sharing options...
jahlxx Posted March 30, 2022 Author Share Posted March 30, 2022 Ok. Please, see attached. HTMLFrame.zip Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 30, 2022 Share Posted March 30, 2022 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; Quote Link to comment Share on other sites More sharing options...
jahlxx Posted March 31, 2022 Author Share Posted March 31, 2022 Ok, thanks. 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? Thanks. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 TeamViewer? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 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... Quote Link to comment Share on other sites More sharing options...
jahlxx Posted March 31, 2022 Author Share Posted March 31, 2022 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 Are you sure you are capturing the event on this component?: 19 minutes ago, jahlxx said: ftemas46.UniHTMLFrame1 Quote Link to comment Share on other sites More sharing options...
jahlxx Posted March 31, 2022 Author Share Posted March 31, 2022 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. ???? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 54 minutes ago, jahlxx said: But nothing happens. TeamViewer? Quote Link to comment Share on other sites More sharing options...
jahlxx Posted March 31, 2022 Author Share Posted March 31, 2022 Yes, please Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 31, 2022 Share Posted March 31, 2022 8 minutes ago, jahlxx said: Yes, please Please, send to PM. Quote Link to comment Share on other sites More sharing options...
jahlxx Posted April 1, 2022 Author Share Posted April 1, 2022 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 1, 2022 Share Posted April 1, 2022 Hello, Yes, it's possible. Quote Link to comment Share on other sites More sharing options...
jahlxx Posted April 1, 2022 Author Share Posted April 1, 2022 Ok. How? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 1, 2022 Share Posted April 1, 2022 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; Quote Link to comment Share on other sites More sharing options...
jahlxx Posted April 1, 2022 Author Share Posted April 1, 2022 Ok. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.