Forum Moderators: open
I need to be advised which direction to take to acheive the required results. Any help would greatly be appreciated.
Thank You,
AndreL
Or are you displaying 1000 items on the screen, and want a random onClick action on each one?
If all links are the same, why are they stored 1000 times?
What are you using the Index Number for?
Are the "if statements" in your javascript, or in the ASP?
Why are you creating an object then comparing it to something random, when you could just choose a random object?
You need to start over and ask your question again. Explain what you're doing, and be clear with words like "table" (HTML table, or database table?), and "script" (javascript, or ASP script?).
Thank you HTTPWEBWITCH for your inquiry, I hope that this clarifies things a bit.
You've already got ASP code that writes the link with an onClick event that calls a JavaScript function. You need one extra ASP variable. Set that variable to 1 when you declare it. Where you write the link, put the value of the variable inside the brackets for the function in the onClick event, then increment (increase by one) the value of the ASP variable before you write the next link.
e.g.
the first link looks something like this:
<a href="#" onClick="myFunction(1)">blah</a>
the second link looks something like this:
<a href="#" onClick="myFunction(2)">blah</a>
the third link looks something like this:
<a href="#" onClick="myFunction(3)">blah</a>
and so on.
Now, make your function accept an argument (the number passed by the link) like this:
function myFunction(cell) {
alert("The user clicked on cell number " + cell)
}
You now have a JavaScript variable called "cell" in your function that contains the value of the cell number they clicked on. Compare this to your random number and... you know the rest.