Click to See Complete Forum and Search --> : checkbox/radio button values..


xataku_nakusute
07-24-2003, 07:27 PM
how exactly do you write radio button/checkbox values in javascript?

eg:
say i wanted to add a few more textboxes or enable a field depending on whether/which radio button/checkbox is clicked....
how would i write the value for it in an if statement in my script?

also, how would you do the same with a <select> and <option> item?

Jupac
07-24-2003, 07:32 PM
you can use this
<INPUT TYPE="Checkbox" NAME="yahoo" VALUE="checked"><a href="http://www.yahoo.com" class="engines">Yahoo!</a>

Jupac
07-24-2003, 07:36 PM
Sorry i put the worng thing

Corect 1
<INPUT TYPE="Checkbox" NAME="yahoo" VALUE="" checked><a href="http://www.yahoo.com" class="engines">Yahoo!</a>

xataku_nakusute
07-24-2003, 07:41 PM
im asking how would you refer to whether or not the radio button/checkbox/option is selected or not in a javascript code?

if you cant answer that, then how would you make it so that when you check a checkbox/select a radio button, you make a certain number and type of fields appear?

Jupac
07-24-2003, 10:25 PM
if you want to check a box and some feilds come out use this
style="visibility:hidden
style=visibility:visible

It is some thing like this

!!!!!!!!!!NOTE THIS DOSE NOT RELLY WORK I AM IN A HURRY TO GET TO MY BASKETBALL GAME!!!!!!SORRY!!!!
<form name=in onclick="this.feild1.style.visibility='visible" >
<input name="feild1" type="text" style="visibility:hidden;">
<input type=checkbox >
</form>

But it should give you an idea
:(

pyro
07-24-2003, 10:32 PM
To check if a radio button is checked you use something like this:

<script type="text/javascript">
function checkVals(frm) {
if (frm.myradio[0].checked) { /*note the [0] this is because radio buttons are returned as an array. If you have two radio buttons named myradio, the first is referenced with [0] and the second with [1]*/
alert ("Yes, it is checked");
}
else {
alert ("No, it is not checked");
}
}
</script>

with this being your form:

<form name="myform">
<input type="radio" name="myradio" value="something">
<input type="button" value="Check" onclick="checkVals(this.form);">
</form>

xataku_nakusute
07-25-2003, 12:09 AM
thank you!