AdamBrill
12-08-2002, 10:00 PM
I have a question for you guys... Here is some code:
<html>
<script language=javascript>
document.write("<Form>");
for(x=0;x<3;x++)
{
document.write("<input type='button' Name='test'+x onclick='OpenLink(x)' value='value'>\n");
}
document.write("</Form>");
function OpenLink(x)
{
alert(x)
}
</script>
</html>
It generates three buttons and runs the OpenLink function when you click on one. The problem is that all of the buttons return what x is currently at (3) when the button is clicked. I wan't them to return the number of the button that was clicked. I hope that wasn't to confusing... :) Let me know if you don't know what I mean... Thanks, Adam
<html>
<script language=javascript>
document.write("<Form>");
for(x=0;x<3;x++)
{
document.write("<input type='button' Name='test'+x onclick='OpenLink(x)' value='value'>\n");
}
document.write("</Form>");
function OpenLink(x)
{
alert(x)
}
</script>
</html>
It generates three buttons and runs the OpenLink function when you click on one. The problem is that all of the buttons return what x is currently at (3) when the button is clicked. I wan't them to return the number of the button that was clicked. I hope that wasn't to confusing... :) Let me know if you don't know what I mean... Thanks, Adam