...

View Full Version : Disabling input field if radio not equal to yes..



jebster
07-13-2003, 03:59 AM
I have a text input field that I want disabled or readonly or whatever, unless the user selects the radio button with the value "yes"! How would I do this? Every attempt I have made has failed... I have very little skills when it comes to javascript! :(

Thanks :)

ACJavascript
07-13-2003, 05:04 AM
Well im not sure what type of browser support it will have but this does the trick
-----

<script language="javascript">

function check1(){
if(document.form1.box1.checked==true){
document.form1.input1.disabled=false
}else{
document.form1.input1.disabled=true
}
}
window.onload=check1
</script>

<form name="form1">
<input type="text" name="input1">
<BR>
<input type="radio" name="box1" onClick="check1()">
</form>

jebster
07-13-2003, 07:58 AM
Cool thanks! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum