Jump to content

about select tag in html


azharschools

Recommended Posts

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

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...