R
reneecccwest
Hello, Aren't they same conditional statment to show the resut?
but somehow "switch" condtional stmt always gets the default value when I excute?
what did I wrong?
<script language="JavaScript">
<!--
function showtype(obj) {
if (obj.options[obj.selectedIndex].value == "137")
{
document.getElementById('secID1').style.visibility = 'visible'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
else if (obj.options[obj.selectedIndex].value == "136")
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'visible'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
else if (obj.options[obj.selectedIndex].value == "135")
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'visible'
document.getElementById('depID1').style.visibility = 'hidden'
}
else if (obj.options[obj.selectedIndex].value == "134")
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'visible'
}
else
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
}
//-->
</script>
vs
<script language="JavaScript">
<!--
function showtype(obj) {
var selectfrmvalue = obj.options[obj.selectedIndex].value
switch (selectfrmvalue)
{
case 134:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'visible'
break
case 135:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'visible'
document.getElementById('depID1').style.visibility = 'hidden'
break
case 136:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'visible'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
break
case 137:
document.getElementById('secID1').style.visibility = 'visible'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
break
default:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
}
//-->
</script>
but somehow "switch" condtional stmt always gets the default value when I excute?
what did I wrong?
<script language="JavaScript">
<!--
function showtype(obj) {
if (obj.options[obj.selectedIndex].value == "137")
{
document.getElementById('secID1').style.visibility = 'visible'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
else if (obj.options[obj.selectedIndex].value == "136")
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'visible'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
else if (obj.options[obj.selectedIndex].value == "135")
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'visible'
document.getElementById('depID1').style.visibility = 'hidden'
}
else if (obj.options[obj.selectedIndex].value == "134")
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'visible'
}
else
{
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
}
//-->
</script>
vs
<script language="JavaScript">
<!--
function showtype(obj) {
var selectfrmvalue = obj.options[obj.selectedIndex].value
switch (selectfrmvalue)
{
case 134:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'visible'
break
case 135:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'visible'
document.getElementById('depID1').style.visibility = 'hidden'
break
case 136:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'visible'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
break
case 137:
document.getElementById('secID1').style.visibility = 'visible'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
break
default:
document.getElementById('secID1').style.visibility = 'hidden'
document.getElementById('brhID1').style.visibility = 'hidden'
document.getElementById('divID1').style.visibility = 'hidden'
document.getElementById('depID1').style.visibility = 'hidden'
}
}
//-->
</script>