I am trying to display/hide different div tags when a checkbox is checked and when a California is selected as a drop-down value. I have it working when the check-box is selected and choosing the drop-down value, but not when the drop-down is selected and clicking the check-box.
I hope this is an easy fix and my newbie-ness is at fault.
<script type="text/javascript" language="JavaScript"><!--
function show(obj)
{
sel = obj.options[obj.selectedIndex].value;
if(sel=='CA' && document.form1.same.checked == true)
{
document.getElementById('CA-sales-tax').style.display = 'block';
document.getElementById('CA-total').style.display = 'block';
document.getElementById('normal-total').style.display = 'none';
}
else
{
document.getElementById('CA-sales-tax').style.display = 'none';
document.getElementById('CA-total').style.display = 'none';
document.getElementById('normal-total').style.display = 'block';
}
}
function show2()
{
if(document.form1.state.selectedIndex == 'CA')
{
document.getElementById('CA-sales-tax').style.display = 'block';
document.getElementById('CA-total').style.display = 'block';
document.getElementById('normal-total').style.display = 'none';
}
else
{
document.getElementById('CA-sales-tax').style.display = 'none';
document.getElementById('CA-total').style.display = 'none';
document.getElementById('normal-total').style.display = 'block';
}
}
//--></script>
<form name="form1" method="post" action="/cart/" enctype="multipart/form-data">
<select name="state" onchange="show(this)">
<option value="">Select US State</option>
<option value="AZ">Arizona</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
</select>
<br>
<br>
<input name="same" type="checkbox" value="1" onSelect="show2()"> same as above
</form>
<br>
<br>
<div id="CA-sales-tax" style="display: none;">ca sales tax</div>
<div id="CA-total" style="display: none;">ca total</div>
<div id="normal-total" style="display: block;">standard total</div>