Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stringing a variable

Status
Not open for further replies.

rickpill

Programmer
Feb 28, 2002
108
US
Hi,

I am new to Javascript (mainframe background ) - I need some help!

I have a pop-up window with a drop down box where users selects any one of 7 options. Based on an option selected, I have to retrieve information from the main window: How do I string a variable form field name?

window.opener.document.all.???.value

where: ??? = "Selection1"

Thank you in advance,

Rick Pillay

 
Would something like this work?

window.opener.document.formname.fieldname.value;

I think that might be what you are looking for...
 
Thanks.

The 'fieldname' is a variable not a form field name.


Rick
 
Oh, sorry. ;) Try this instead:

window.opener.fieldname;

That should return the fieldname variable from the window that opened the page.
 
Thanks!

Sorry, I don't think I explained this properly ...

parent.window:
Line1 'Buyer '
Line2 'Seller '
Line3 'Subscriber '

pop up window:
option 1
option 2
option 3 <==== Selected
.................
: Category: 123 :
.................

From the pop up window I need to string to Line3 (Parent window) the value 'Category: 123'. I am currently doing this with a bunch of 'if' statements - is there an easier way to do this, i.e. create a variable, string 'Line' + the Option selected into:
window.opener.document.formname.fieldname.value;

Thanks again,

Rick




 
So, you have a <select> and you want to know which one it is on? If so, try something like this:

Code:
window.opener.document.formname.selectname.options[window.opener.document.formname.selectname.selectedIndex].value; //all that on one line

I think that might be what you want... ;-)
 
Rick,

An eval statement might be helpful for you, there.

Here's a link to a discussion involving eval statements to build commands using variables:
thread216-478576

Cheers,
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Thanks AdamBrill and Edward! Just got back.

Edward, I'll give that a try. Thanks.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top