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

passing array number with onclick

Status
Not open for further replies.

pkailas

Programmer
Jun 10, 2002
555
US
how does one pass the specific array number to a function with the onclick? I have 5 different elements in my array such as jvar[0], jvar[1], etc. I wish to bring up one of these when I use the onclick.
 
<input type=button onClick=&quot;myFunction(1)&quot; value=&quot;button 1&quot;>

<script>
myArr = new Array (&quot;message 1&quot;, &quot;Message 2&quot;)
function myFunction(inNum){
alert (myArr[inNum])
}
</script> -----------------------------------------------------------------
&quot;The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.&quot;
- unknown

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top