Welcome to WebmasterWorld Guest from 54.226.147.190

Forum Moderators: open

Message Too Old, No Replies

Dropdown doing 2 functions

uncheck then disable checkbox

     

LinuxGold

11:27 am on Sep 23, 2005 (gmt 0)

10+ Year Member



If I select a dropdown menu, I would like to uncheck a checkbox THEN disable it. How do I get around to it?


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link href="Includes/css/chrome.css" rel="stylesheet" type="text/css">
<title>QC Data Entry</title>
<script type="text/javascript">
function makeDisable()
{
var x=document.getElementById("PMFlag");
x.disabled=true;
}
function makeEnable()
{
var x=document.getElementById("PMFlag")
x.disabled=false
}
function uncheck()
{
var y=document.forms.myForm;
y[0].checked=false;
}

</script>
</head>
<body>
<form autocomplete="off" action="QADE_java.htm" method="post" name="myForm">

<select>
<option onclick="makeEnable()"></option>
<option onclick="makeDisable()" value="foo">Foo</option>
</select>
<input type="checkbox" id="PMFlag" />
</form>
</body>
</html>

Bernard Marx

12:07 pm on Sep 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



----html------

<select onchange="checkboxEnable(this)" >
<option value="doo">enable</option>
<option value="daa">disable</option>
</select>
<input type="checkbox" id="PMFlag"/>

----script-----

function checkboxEnable(select)
{
var value = select.options[select.selectedIndex].value;
document.getElementById("PMFlag").disabled
= (value == 'daa')? true : false;
}

LinuxGold

12:31 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



That still won't uncheck the checkbox before it is disabled.

Bernard Marx

1:57 pm on Sep 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



function checkboxEnable(select)
{
var value = select.options[select.selectedIndex].value;
var cBox = document.getElementById("PMFlag");
if(value == 'daa')
{
cBox.wasChecked = cBox.checked;
cBox.checked = false;
cBox.disabled = true;
}
else
{
cBox.checked = Boolean(cBox.wasChecked);
cBox.disabled = false;
}
}

LinuxGold

2:48 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



Thanks!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month