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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i add varibable to document.forms 3

Status
Not open for further replies.

louistaub

Programmer
Sep 21, 2001
20
0
0
GB
At the moment I can update an input box using this code.

parent.Details.document.forms[0].Qty_0.value=123

But there are a number of Qty boxes on my form eg Qty_1, Qty_2. What I would like to do is put a variable in place of the Qty_0, eg

parent.Details.document.forms[0].variable.value=123

this obviously doesn't work, so does any one know of a way of achieving this.

Thanks

Louis
 
louistaub-

Try setting the variables in JavaScript like this:

varName = control;

When you call this variable in the body of your script, simply refer to it by variable name. For example, if you were to set the text for a control in your form as stated above, you would simply declare the variable as:

varName = parent.Details.document.forms[0].Qty_0;

When setting the text, you would write:

varName.value = "123";

If this isn't the kind of functionality that you were looking for, please let me know, and I'll try something different. Hope it helps.
 
do this instead:
Code:
parent.Details.document.forms[0][variable].value=123
(-:
 
Thanks a lot, both solutions work well

Thanks again

Louis
 
Hey stak, I've never seen that solution before. Cool! Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
it's from the brilliant book "Javascript - The Definitive Guide" by David Flanagan (O'reilly ISBN: 1-56592-392-8)
alot of useful examples and tricks in that book :) (-:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top