Page 1 of 1

Dropdowns should show each div - but don't...

Posted: Tue Jul 03, 2012 8:24 am
by simonmlewis

Code: Select all

<script>
function updateSelect(obj){
    div = document.getElementById("salt");
    if(obj.options[obj.selectedIndex].value == "PLEASE PAINT"){
        if(div.style.display == "none")
            div.style.display = "inline";
    }else{
        div.style.display = "none";
        document.getElementById("salti").value = "";
    }
    
    
    div = document.getElementById("short");
    if(obj.options[obj.selectedIndex].value == "SHORT"){
        if(div.style.display == "none")
            div.style.display = "inline";
    }else{
        div.style.display = "none";
        document.getElementById("salti").value = "";
    }
    
}
</script>
-
-
-
-
-
echo "
<select name='itemname2' onchange=\"updateSelect(this)\">
<option value='0'>PLEASE SELECT</option>
<option value='SHORT'>SHORT</option>
<option value='MEMBER'>SITE MEMBER</option>
<option value='PLEASE PAINT'>PLEASE PAINT</option>
</select>

<div id='salt' style='display:none; font-size: 12px'><div class='usercommentsform' style='margin-top: 0px; margin-bottom: 4px; background-color: #ffffff;'>
text will be here for paint</div>
</div></div>


<div id='short' style='display:none; font-size: 12px'>
<div class='usercommentsform' style='margin-top: 0px; margin-bottom: 4px; background-color: #ffffff;	background-image: url(/images/bg_paintedprice.png); background-repeat: repeat-x;'>
text will be here for short
</div>
</div>

I need each separate dropdown selection to make these DIVs appear. It works for "salt" but not for "short".

I am sure it is how I am using the salt word, in the SCRIPT at the top. Any ideas?

Re: Dropdowns should show each div - but don't...

Posted: Wed Jul 18, 2012 5:12 pm
by avibitton
look what i wrote at the comment . scroll down
div = document.getElementById("short");
if(obj.options[obj.selectedIndex].value == "SHORT"){
if(div.style.display == "none")
div.style.display = "inline";
}else{
div.style.display = "none";
document.getElementById("salti").value = ""; ----------------------- ------------------> it shouldnt be here short instead of salti ? cause like that your not canceling the display none
}

}
</script>


good luck Avi .