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

Question about object arrays

Status
Not open for further replies.

knuckle05

Programmer
Dec 17, 2001
247
CA
Hi All,

Could someone please help me with this.

I would like to do an array of hidden textboxes to hold an identity key.

Do I need to reference each one differently like txt1, txt2, txt3, etc. or can I keep the same name for each box? If so, how would I reference it afterwords, meaning, how could I be sure that I'm looking at the correct value.

I'm sure of seen something like this before regarding checkbox arrays in HTML. Any help would be greatly appreciated.

thx
 
U can use the same name for each like so:

<form id=&quot;ff&quot; name=&quot;ff&quot;>
<input id=&quot;tx1&quot; name=&quot;tx1&quot; value=&quot;one&quot; />
<input id=&quot;tx1&quot; name=&quot;tx1&quot; value=&quot;two&quot; />
<input id=&quot;tx1&quot; name=&quot;tx1&quot; value=&quot;three&quot; />
</form>
<SCRIPT LANGUAGE=javascript>
<!--
function displayit(){
alert(document.ff.tx1[0].value);
}
//-->
</SCRIPT>

Hope this helps
-pete

<input type=&quot;button&quot; value=&quot;go&quot; onclick=&quot;displayit()&quot;/>
 
Thanks,

It makes sense. What I want to do though is have a list of hyperlinks with a value inside the hidden textbox beside that hyperlink.

If I click on the 4th hyperlink and would like to get ID# 4 from the hidden textbox, how can I reference it if it is called [tx1]? I know that in js i could do a tx1[3], but how can I get that ordinal value?
 
<form>
<a onclick=&quot;displayit(0);&quot;>ONE</a>
<input id=&quot;tx1&quot; name=&quot;tx1&quot; value=&quot;one&quot; />
<a onclick=&quot;displayit(1);&quot;>ONE</a>
<input id=&quot;tx1&quot; name=&quot;tx1&quot; value=&quot;two&quot; />

</form>
<SCRIPT LANGUAGE=javascript>
<!--
function displayit(n){
alert(document.ff.tx1[n].value);
}
//-->
</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top