Jump to content
sunziun

Drop Down Dependencies

Recommended Posts

Hello very one, I've this peace of code which I cannot make it work. please some one help me with this

<script type="text/javascript"> function disDropDown(){if(document.getElementById("one").value === "yes"){document.getElementById("two").disable='true'} else{document.getElementById("two").disable='false'}}</script> <form><select id="one"><option value="yes">Yes</option><option value="no">No</option></select> <select id="two"><option value="1">1</option><option value="2">2</option></select></form>

Share this post


Link to post
Share on other sites

Where are you calling that function? With select elements you typically use the selectedIndex property and the options property to get the value, instead of the value property. And I believe the property to disable something is called "disabled". http://www.w3schools.com/jsref/dom_obj_select.asp

Share this post


Link to post
Share on other sites

I would like disable the whole drop down called "one" by using onChange() <select id="one" onChange="disDropDown()"><option value="yes">Yes</option><option value="no">No</option></select> I would like to use the value, not value property!

Edited by sunziun

Share this post


Link to post
Share on other sites

The select element has a property called options which is an array of the options they can select, and it has a property called selectedIndex which is the index of the selected option in the options array. That option has a value property that you can use to get the value of the selected option.

Share this post


Link to post
Share on other sites

I am sorry but I don't get you. can you give examples?

Share this post


Link to post
Share on other sites

Sorry but I don't how to use this. please give me comprehensible example. thanks anyways.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...