Re: A select drop-down that appears/disappears according to previous selection.
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: A select drop-down that appears/disappears according to previous selection.

From: pk <philip.kluss@gmail.com>
Date: Wed Aug 31 2005 - 17:00:10 CEST

OK, when I initially posted this, I didn't think I was all that close
to having it work. Now I swear it should be working, but it's not.
I'm posting some simplified code with comments of my thought process
(SCARY!). Tell me where I went wrong please. :) (These comments don't
truly exist in my code, I added them for insight. They're commented
Java-style since I don't write in HTML or JavaScript.)

Thanks for helping. I realize this is frustrating and you probably
just want to tell me to go read a JavaScript book.

<html>
<SCRIPT type="text/javascript"> >

function able(dropdown)

{
        var myindex =
document.myform.dropdown.options[document.myform.dropdown.selectedIndex].value
        // the line above put the value of my dropdown menu selection in the
variable myindex. this value will be 0, 1, or 2.
                if(myindex == 1) {
                document.getElementById('BalStepDiv').style.visibility="visible";
                document.myform.BalStepVal.focus();
                // in the case that myindex is equal to 1, i would like
to set the BalStepDiv <div> to visible.
        }
        else {
                document.getElementById('BalStepDiv').style.visibility="hidden";
                // in the case that myindex is not equal to 1, i would
like to set the BalStepDiv <div> to hidden.
}

</SCRIPT>

<body>
<Form Name="myform">
Test Select:
<select name="Finish" onchange='able(this);'>
        <option></option> //selectedIndex == 0
        <option>Rough</option> //selectedIndex == 1
        <option>Finish</option> //selectedIndex == 2
</select>

<div id=BalStepDiv style="visibility:hidden;">
// the line above sets everything between the <div> </div> tags to
hidden, until that is changed by the function above.
<select name=BalStepVal>
        <option></option>
        <option>Balanced Cutting</option>
        <option>Step Cutting</option>
</select>
</div>
</form>
</body>
</html>
Received on Tue Oct 18 03:15:14 2005