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

building hidden fields on the fly, need to build js Elements to match

Status
Not open for further replies.

timcadieux

Programmer
May 25, 2005
129
0
0
BE
Hey folks, i'm building a table that has File fields, dependant on a number that the user inous, ie.. they type 5 and my script builds 5 file fields named Filename0, filename1, etc...

I simply use the value of request.form("num") and loop

Using the below code, i get the value from a hidden field, but it only works if i have just the one field. Can i use the above loop to make my javascript just as dynamic so it refers to multiple hidden fields?

Code:
function DisplayImage(ImageName,ElementValue){
document.images[ImageName].src=ElementValue;
document.forms['myForm'].elements['hidden_ImgSrc'].value = ElementValue;
			}
 
Certainly - you can use the following to address any numbered field:

Code:
document.forms['myForm'].elements['hidden_ImgSrc'[b] + loop[/b]].value = ElementValue;

Where loop is an integer number to be appended to 'hidden_ImgSrc' to make the final form input name ('hidden_ImgSrc0', 'hidden_ImgSrc1' ... 'hidden_ImgSrcn').

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
ok, sorry, haven't had lunch so i'm a little looopy myself! ;-)
 
actually, in doing this im seeing i have to logic incorrect. I can easily create the hidden fields, but what i need the javascript to do is update the matching hidden field only, ex..

Filename4 should update hidden4

that way only those that get changed by the client would actually be changed. The way i originally was looking at it, all fields would be updated, that's not necessary.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top