...

View Full Version : when selection is made checkbox is enabled. otherwise checkbox is disabled.



Mthor
09-24-2008, 10:43 PM
alright guys how is everbody today?

I have a situation where I need some help.

I have a combo box and a check box.

in the code below. when selection 3 is made I need the checkbox to enable. otherwise check box is disabled.



<select name="menu" size="3">
<option value="1">selection 1</option>
<option value="2">selection 2</option>
<option value="3">selection 3</option>
<option value="3">selection 4</option>
<option value="3">selection 5</option>
</select>

<input name="" type="checkbox" value="" />



thanks for the help

ohgod
09-24-2008, 10:52 PM
<select name="menu" size="3" onchange="check();">
<option value="1">selection 1</option>
<option value="2">selection 2</option>
<option value="3">selection 3</option>
<option value="3">selection 4</option>
<option value="3">selection 5</option>
</select>

<input name="yourcheckbox" type="checkbox" value="" disabled="true"/>


function check(){
if (document.formname.menu.value == '3'){ document.formname.yourcheckbox.disabled=false;}else{document.formname.yourcheckbox.disabled=true;}

}



maybe there's a better way, that just came to me first

Mthor
09-24-2008, 11:04 PM
i tried that. but it didn't work.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function check(){
if (document.formname.menu.value == '3'){ document.formname.yourcheckbox.disabled=false;}else{document.formname.yourcheckbox.disabled=true;}

}
</script>
</head>

<body>
<select name="menu" size="3" onchange="check();">
<option value="1">selection 1</option>
<option value="2">selection 2</option>
<option value="3">selection 3</option>
<option value="3">selection 4</option>
<option value="3">selection 5</option>
</select>

<input name="yourcheckbox" type="checkbox" value="" disabled="true"/>
</body>
</html>

ohgod
09-25-2008, 12:38 AM
yeah.... you don't have a form. i thought you posted incomplete code.

anyway, you need to build it out like a form, with <form> tags and all that. looks it up on w3schools if you're unfamiliar with it.

Mthor
09-25-2008, 05:08 AM
OMG I cant believe I forgot that.


thanks for all your help. it works great.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum