dewcansam
11-11-2002, 08:32 PM
Alright I've searched javascript.com, javascriptkit.com, and the forum and can't seem to find exactly what I am after.
So "What are you after" you ask. Well I would like to reference a form element by an argument passed to a function. Can this be done? What is the correct syntax if it can be achieved? Or maybe you have a better way to do this?
Code snip
[code]
<script>
function checkTheBox (someArg) {
document.myForm.someArg.checked = 1;
}
</script>
<form name=myForm>
<input type=button value="Click Me" onClick="checkTheBox('c01');">
<input type=checkbox name="c01">c01<br>
</form>
[code]
So "What are you after" you ask. Well I would like to reference a form element by an argument passed to a function. Can this be done? What is the correct syntax if it can be achieved? Or maybe you have a better way to do this?
Code snip
[code]
<script>
function checkTheBox (someArg) {
document.myForm.someArg.checked = 1;
}
</script>
<form name=myForm>
<input type=button value="Click Me" onClick="checkTheBox('c01');">
<input type=checkbox name="c01">c01<br>
</form>
[code]