Randy Webb <HikksNotAtHome (AT) aol (DOT) com> wrote in
news:ILadne1Q9eQgXKzZ4p2dnA (AT) comcast (DOT) com:
Quote:
Tony Rice said the following on 4/3/2006 8:44 PM:
Randy Webb <HikksNotAtHome (AT) aol (DOT) com> wrote in
news:ILadnfBQ9eTgXazZ4p2dnA (AT) comcast (DOT) com:
URL: http://www.jibbering.com/faq/faq_not...ess.html#faBut
Will show you how to get the value of a Radio Button.
That's pretty much what I'm doing, but with a named id. Not working
though.
Give them a name. |
I'm using document.getElementById, like so:
<script type="text/javascript">
function showfield(id){
var sourceid='type_'+id;
var targetid='update_'+id;
var value=getRadioValue(sourceid);
if (value == 'c'){
document.getElementById(targetid).style.display = 'block';
}else{
document.getElementById(targetid).style.display = 'none';
}
}
function getRadioValue(obj){
if (!obj){
return;
}
for(var i=0;i<obj.length;i++){
if (obj[i].checked){
return(obj[i].value);
break;
}
}
return "unknown";
}
<script>
<input name="type_1" id="type_1" type="radio" value="a"
onChange="showField('1')">a
<input name="type_1" id="type_1" type="radio" value="b"
onChange="showField('1')>b
<input name="type_1" id="type_1" type="radio" value="c"
onChange="showField('1')>c
<div style="display: block;" id="update_1"><textarea name="update_1">
</textarea></div>