Hello all ~ I have a script that worked great until I wanted to change from a check-box to a selection-options. I have no errors per say it just doesn't 'work'.
Here's what I want to have happen: in my selection drop down list the first will be a default value, if the visitor selects any of the other choices I want my text surrounded by <div id= to appear, otherwise if the default is their choice then the text can remain hidden.
Here is my code that worked when I was using a check box -
Code:<script type="text/javascript"> $(function() { $('#user_input').change(function() { $('#use_user_input').val($(this).val()); }); }); function showhidefield(element, id) { var node = document.getElementById(id); if (node) { node.style.display = element.checked ? 'block' : 'none'; } } </script>
But now I need it to work for a selection - like this:HTML Code:<form> <input type="checkbox" name="choose" onclick="showhidefield(this, 'hideablearea')"> Please send me more info. <br> <div id="hideablearea" style="display:none;"> <p>This is the area to display when they checked the box</p> </div>
What do I need to change so that all the options besides the default will cause my text to appear?HTML Code:<select name="choose" onChange="showhidefield(this, 'hideablearea')"> <option selected="selected" value="">Anything is good to me.</option> <option value="m1">Veggies</option> <option value="w2">Fruit</option> <option value="y3">Meat</option> </select>
I've searched and searched but haven't found my exact problem.
Thanks for your help.


Reply With Quote

Bookmarks