Page 1 of 1

BrowserGetElement and multiple forms

PostPosted: Mon Jan 07, 2013 7:47 pm
by dpayer
If we have more than one form on a web page and both forms have an element named "Name", how can we differentiate between the forms with this NB command?

example:
Code: Select all
<form method="POST" name="form1" action="Neobook:SetVar "[MyVar1]" "Value1"">
   <p><input type="text" name="Name" size="20"></p>
   <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<form method="POST" name="form2" action="Neobook:SetVar "[MyVar2]" "Value2"">
   <p><input type="text" name="Name" size="20"></p>
   <p><input type="submit" value="Submit" name="B3"><input type="reset" value="Reset" name="B4"></p>
</form>



David P.

Re: BrowserGetElement and multiple forms

PostPosted: Tue Jan 08, 2013 7:18 am
by dec
Hello,

Doing some test, apparently, the referer command only retrieve the first element of the HTML document. However, maybe you can get more precission using some little JavaScript with the appropiate action. Do you? ;)

Re: BrowserGetElement and multiple forms

PostPosted: Tue Jan 08, 2013 7:32 am
by dpayer
dec wrote:Hello,

Doing some test, apparently, the referer command only retrieve the first element of the HTML document. However, maybe you can get more precission using some little JavaScript with the appropiate action. Do you? ;)



It is never a problem if I am the one who creates the web page. There are ways around it then. I think with javascript, I would 'getelementbyid' and then parse the form's by id. This question came up as I was working on another project where I am using the NB comnand 'BrowserGetElement' and I realized I could not address the issue of multiple forms on a page properly. I had not planned to need parse sections with javascript though.

It is not a priority at this moment. I would like to hear Neosoft's view on how to use the command in a multi-form environment.

Thanks for your input DEC.

David P.

Re: BrowserGetElement and multiple forms

PostPosted: Tue Jan 08, 2013 8:05 am
by Gaev
David P:

You could use BrowserExecScript instead ... navigate to the Form (whose names are unique) ... and then to its child element with name of 'Name' ... then get/set its value.

You can run BrowserExecScript against any document in the Web Browser object ... after it is loaded.

Re: BrowserGetElement and multiple forms

PostPosted: Tue Jan 08, 2013 11:50 am
by Neosoft Support
Currently, there isn't any way to differentiate between multiple elements with the same name using BrowserGetElement. It might be possible to modify BrowserGetElement to do this. We're working on a maintenance update right now. I will see if there is time to address this issue.

Re: BrowserGetElement and multiple forms

PostPosted: Tue Jan 08, 2013 12:37 pm
by dpayer
Neosoft Support wrote:Currently, there isn't any way to differentiate between multiple elements with the same name using BrowserGetElement. It might be possible to modify BrowserGetElement to do this. We're working on a maintenance update right now. I will see if there is time to address this issue.



Thanks for responding. This is not a critical issue at this time. Do not rush to include this on my behalf. It would be good to see it in the future.

David P.

Re: BrowserGetElement and multiple forms

PostPosted: Thu Jan 10, 2013 6:17 am
by Tony Kroos
:facepalm

dpayer wrote:This is not a critical issue at this time. Do not rush to include this on my behalf. It would be good to see it in the future.

it's not critical at all, you already have everything to get the job done.
1. BrowserExecScript - handle all specified name tags in document (ascending order 0,1...n)
Code: Select all
var x = document.getElementsByName('Name');
alert (x.item(0).value);
alert (x.item(1).value);

2. BrowserExecScript - handle name tags in given form
Code: Select all
var f = document.forms[#91]'[FormName]'[#93]
alert (f.elements[#91]'Name'[#93].value)

or simply
Code: Select all
alert (document.[FormName].Name.value)

dont forget to setvar [FormName] with the name of preferred form first

Let developers pay attention to really important issues (they say that updates coming :shock: )

Re: BrowserGetElement and multiple forms

PostPosted: Thu Jan 10, 2013 9:39 am
by dpayer
Tony Kroos wrote::facepalm
it's not critical at all, you already have everything to get the job done.

Let developers pay attention to really important issues (they say that updates coming :shock: )


Thank you Tony.

David P.

Re: BrowserGetElement and multiple forms

PostPosted: Thu Jan 10, 2013 10:33 am
by Tony Kroos
btw, good article here take a look

Re: BrowserGetElement and multiple forms

PostPosted: Thu Jan 10, 2013 2:11 pm
by Neosoft Support
Thanks Tony!