Need help with "radio buttons" script, please

wxdqz

New Member
Hello all. I was thrilled to find a script that would replace those "old ugly radio buttons in your forms" and it's short and sweet but I can't get it to work when I try to modify it to suit my needs.

<!-- m --><a class="postlink" href="http://javascript.internet.com/forms/radio-buttons.html">http://javascript.internet.com/forms/radio-buttons.html</a><!-- m -->

Here's what I'm up to: the script includes a feature to have the name of the "option" appear in an input box above the list of radio buttons. Well, seeing no practical purpose for this and I certainly didn't need it on my page, I removed the reference in the script for the "action" involving this input box. The script still worked fine until I went to add my own variables. Here's what I've got:

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <!-- m --><a class="postlink" href="http://javascript.internet.com">http://javascript.internet.com</a><!-- m --> -->
<!-- Evaldo Nunes (<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->) -->

<!-- Begin
function Check(x,y) {
for(i=1;i<=4;i++) {
z = "option" + i ;
document.all[z].src = "images/off.gif" ;
}
document.all[x].src = "images/on.gif"
}
// End -->
</script>

I removed the line: document.all.action.value = x

And for the buttons themselves, the demo uses this:

<a href=http://www.webdeveloper.com/forum/archive/index.php/"#"><img border="0" src="images/on.gif" width="11" height="11" name=option1
onclick=Check(this.name,"home.asp")></a> option 1

<a href="#"><img border="0" src="images/off.gif" width="11" height="11" name=option2
onclick=Check(this.name,"cadastro.asp")></a> option 2

My options look like this:

<INPUT onclick="setOption(0)" type=radio id="basecolor" name=option checked>Base Color<br>

<INPUT onclick="setOption(1)" type=radio id="facecolor" name=option>Face Color<br>

<INPUT onclick="setOption(2)" type=radio id="trackcolor" name=option>Track Color<br>

.... and this pattern continues for 9 more radio buttons.

How do I adapt my "INPUT onclick=" code to work with the script, and if I didn't remove the reference to the "action" part of the script correctly, what should I have done instead?

Any and all assistance is greatly appreciated.

D.
 
Back
Top