Trigger checkbox when combo box is changed

J

Jason McDonald

I have a PDF form that has a combo box "no_wireless_mics" with the
values "1" "2" and " " where " " is the default. I need a JavaScript
that will cause the check box "wireless_mics" to be checked
(value=true) when the combo box value is "1" or "2"

I ama JavaScript newbie and I'm having quite a time figuring this out.
Thank you for your time and attention.
 
V

Vjekoslav Begovic

Jason McDonald said:
I have a PDF form that has a combo box "no_wireless_mics" with the
values "1" "2" and " " where " " is the default. I need a JavaScript
that will cause the check box "wireless_mics" to be checked
(value=true) when the combo box value is "1" or "2"

I ama JavaScript newbie and I'm having quite a time figuring this out.
Thank you for your time and attention.

For example:

<html>
<head>
<script type="text/javascript">
function miscOnChange(obj){
if ((obj.value == 1) || (obj.value == 2)){
document.getElementById("wirelesmisc").checked=true;
}
else{
document.getElementById("wirelesmisc").checked=false;
}
}
</script>
</head>

<body>
<input type="checkbox" id="wirelesmisc">Wireless
<select id="misc" onchange="miscOnChange(this)">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</body>
</html>

HTH

Vjekoslav
 
E

Egbert Beuker

i think this should work:

<!-- Begin of sample -->

<script language="javascript">
function sel_onchange()
{
document.all.wireless_mics.checked = true;
}
</script>

<select id="no_wireless_mics" name="no_wireless_mics"
onchange="sel_onchange()">
[your options go here]
</select>

<input type="checkbox" id="wireless_mics" name="wireless_mics">

<!-- End of sample -->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top