homepage Welcome to WebmasterWorld Guest from 54.196.62.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Dropdown doing 2 functions
uncheck then disable checkbox
LinuxGold




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

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




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

----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




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

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

Bernard Marx




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

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




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

Thanks!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved