Saturday 15 February 2014

javascript - HTML drop down menu with extra data after click -



javascript - HTML drop down menu with extra data after click -

i need create drop downwards menu in html. thought when click on option, let's city, below menu automatically should appear detailed contact information.

so example. if take london, automatically should appear street address, phone, etc. submit button below, improve without.

<form action="process.php" method='post'> <select name="cities"> <option value="london">london</option> <option value="ny">ny</option> <option value="rome">rome</option> <option value="paris">paris</option> </select> <input type="submit" /> </form>

i'm not in html, appreciate help

is this (check fiddle) looking for??

all need thought on javascript or jquery. code in above fiddle sample or reference. improve usage please refer jquery ajax.

code :

$('#cities').change(function(){ var info = $('#cities :selected').val(); document.getelementbyid("data").style.display = "block"; if(data === "paris") document.getelementbyid("data").innerhtml = "you have selected paris"; else if(data === "rome") document.getelementbyid("data").innerhtml = "you have selected rome"; else if(data === "ny") document.getelementbyid("data").innerhtml = "you have selected ny"; else if(data === "london") document.getelementbyid("data").innerhtml = "you have selected london"; else document.getelementbyid("data").style.display = "none"; });

javascript html drop-down-menu

No comments:

Post a Comment