[RESOLVED] Chained Select, but for a checkbox?
Ok, so I have a drop-down select menu to select "which company" is responsible for a given project... but if a certain one is selected, I need it to offer a checkbox that says something like "this company only?" ... currently we're only working with 1 company that needs this checkbox, because the rest of the companies we work with, we handle all of their business.
Any suggestions?
like so?
Code:
<!DOC HTML>
<html>
<head>
<style>
#cb {display:none}
</style>
</head>
<body>
<select onchange="getElementById('cb').style.display=this.value">
<option value="none"> please select </option>
<option value="none"> company 1 </option>
<option value="block"> company 2 </option>
<option value="none"> company 3 </option>
</select>
<div id="cb"><input type="checkbox"/>Just this one?</div>
</body>
</html>
Sort of like that, yes, but the options' values have to be the ID-numbers of the companies
so like this then?
Code:
<!DOC HTML>
<html>
<head>
<style>
#cb {display:none}
</style>
</head>
<body>
<select onchange="checkId(this.value)">
<option value="111"> please select </option>
<option value="222"> company 1 </option>
<option value="666"> company 2 </option>
<option value="333"> company 3 </option>
</select>
<div id="cb"><input type="checkbox"/>Just this one?</div>
<script type="text/javascript">
function checkId(val){
document.getElementById("cb").style.display=val=="666"?"block":"none";
}
</script>
</body>
</html>
Yes, that should do the trick! I'll give it a shot. Thank you!
Alternative solution (because I'm such a slow typist!)
Code:
<!DOC HTML>
<html>
<head>
<style>
#cb {display:none}
</style>
<script type="text/javascript">
//<![CDATA[
function selectCompany(info) {
var tarr = info.split(':');
document.getElementById('cb').style.display=tarr[0];
alert(tarr[1]); // save or return value is necessary for later use elsewhere
}
//]]>
</script>
</head>
<body>
<select onchange="selectCompany(this.value)">
<option value="none:"> please select </option>
<option value="none:Company 1"> company 1 </option>
<option value="block:Company 2"> company 2 </option>
<option value="none:Company 3"> company 3 </option>
</select>
<div id="cb"><input type="checkbox"/>Just this one?</div>
</body>
</html>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks