![]() |
Selected option
Hello, I am new with javascript and have been trying all day to figure out how do this problem. I am not sure to use the switch or just if function? Basically I want a drop down to give a list of all ipod nano's and based on what generation is selected I want to display the correct storage space in checkboxes under my selection. I was able to get one option to come and go but after adding more I got lost.
This is part of the html: (I am trying to use the div tag's display to hide and populate the area once its selected) Code:
|
You don't have any element with id="nanoIpod", yet to try to address it using getElementById('nanoIpod'). This will definitely fail. So it's time to debug :-)
1. Add an id attribute to the select (let's say "select1") 2. document.getElementById('select1').value will give you the currently selected value of the select inside your onchange handler 3. Depending on the value you can show/hide the depending div's If you need more info, feel free to ask. Please add your updated code then. |
Code:
<select onchange="nanoIpod(this);" name="nanoIpod" class="medium">Another thing: Don't name you functions same as other global variables or as other id or name attributes. |
| All times are GMT +1. The time now is 06:09 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.