azharschools Posted February 26, 2007 Share Posted February 26, 2007 Hai all,I need some help..In my project i have to select country field in one combo box and it will affected next combo box , its name is State combo box.This field is situated in all registration form. But i dont know the correct syntax in the javascript..So, My problem is if i am select the country like india in the combo box and the state of that country(india) will shown in the next combo box.It will shown in all type of registration form.it is my problem. Can you help me its very urgent Link to comment Share on other sites More sharing options...
Lulzim Posted February 26, 2007 Share Posted February 26, 2007 same question have been asked beforehttp://w3schools.invisionzone.com/index.ph...ic=7583&hl=http://w3schools.invisionzone.com/index.ph...amp;#entry60604the first one is with ajax Link to comment Share on other sites More sharing options...
Lepper Posted February 26, 2007 Share Posted February 26, 2007 To access a value of a selected option in javascript you can use the following code in a javascript function that you define: //example that pop up a message with the value of the selected value in a select boxfunction alertSelectedValue(){alert(document.forms[0].yourSelectBoxName[document.forms[0].yourSelectBoxName.selectedIndex].value);} Hope this helps you in your algorythm Link to comment Share on other sites More sharing options...
azharschools Posted February 26, 2007 Author Share Posted February 26, 2007 To access a value of a selected option in javascript you can use the following code in a javascript function that you define://example that pop up a message with the value of the selected value in a select boxfunction alertSelectedValue(){alert(document.forms[0].yourSelectBoxName[document.forms[0].yourSelectBoxName.selectedIndex].value);} Hope this helps you in your algorythm Thank you for your reply,I will use this code and send the feedback to you . Link to comment Share on other sites More sharing options...
Lepper Posted February 27, 2007 Share Posted February 27, 2007 Sorry!! the correct way to access is document.forms[0].yourSelectBoxName.options[document.forms[0].yourSelectBoxName.selectedIndex].valueNote that "options" was added... I forgot to place it in my previos post... sorry.also... you can access a select element by the "document.getElementById(mySelectId)" function (if an id is defined for your select)please read this page with tutorials and properties of the select element Link to comment Share on other sites More sharing options...
azharschools Posted February 28, 2007 Author Share Posted February 28, 2007 To access a value of a selected option in javascript you can use the following code in a javascript function that you define://example that pop up a message with the value of the selected value in a select boxfunction alertSelectedValue(){alert(document.forms[0].yourSelectBoxName[document.forms[0].yourSelectBoxName.selectedIndex].value);} Hope this helps you in your algorythm I tried that code. But its not working.Give any other related codeok thank you for your reply Link to comment Share on other sites More sharing options...
azharschools Posted February 28, 2007 Author Share Posted February 28, 2007 To access a value of a selected option in javascript you can use the following code in a javascript function that you define://example that pop up a message with the value of the selected value in a select boxfunction alertSelectedValue(){alert(document.forms[0].yourSelectBoxName[document.forms[0].yourSelectBoxName.selectedIndex].value);} Hope this helps you in your algorythm I tried that code. But its not working.Give any other related codeok thank you for your reply Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now