Source language: Translate to:

BrowserGetElement and multiple forms

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

BrowserGetElement and multiple forms

Postby dpayer » Mon Jan 07, 2013 7:47 pm

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: BrowserGetElement and multiple forms

Postby dec » Tue Jan 08, 2013 7:18 am

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? ;)
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: BrowserGetElement and multiple forms

Postby dpayer » Tue Jan 08, 2013 7:32 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: BrowserGetElement and multiple forms

Postby Gaev » Tue Jan 08, 2013 8:05 am

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.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: BrowserGetElement and multiple forms

Postby Neosoft Support » Tue Jan 08, 2013 11:50 am

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.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: BrowserGetElement and multiple forms

Postby dpayer » Tue Jan 08, 2013 12:37 pm

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: BrowserGetElement and multiple forms

Postby Tony Kroos » Thu Jan 10, 2013 6:17 am

: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: )
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: BrowserGetElement and multiple forms

Postby dpayer » Thu Jan 10, 2013 9:39 am

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.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: BrowserGetElement and multiple forms

Postby Tony Kroos » Thu Jan 10, 2013 10:33 am

btw, good article here take a look
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: BrowserGetElement and multiple forms

Postby Neosoft Support » Thu Jan 10, 2013 2:11 pm

Thanks Tony!
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest