JavaScript 101
by Bruce Ure at 15:55 04/03/05 (Forum::Technical Advice::General)
I have found loads of info about how to get the value of a checkbox (or any object) when you pass it in to a function as an object, but nothing about how to get it from the name.
I have a function into which I am passing an int which represents the index of a series of controls called things like txtName1, chkBastard1, and so on, to which I want to do unspeakable things.

I want to get the value of chkBastard1 in my function. The following works if I pass it in as an object:

<input type='checkbox' onclick='javascript:DoStuff(this);'>

DoStuff(theCheckbox) {
alert(theCheckbox.checked);
}

But I want to be able to do this:

<input type='checkbox' onclick='javascript:DoStuff(1);'>

DoStuff(intIndex) {
alert(["chkBastard" + intIndex].checked);
}

Is it possible? It MUST be possible.

I will probably do my usual and find the solution 3 minutes from now on t'internet.

:bu:

<< Netatalk and the spinning beac... eBay spoof >>
Powered by
Powered by Novacaster