javascript - getting the value of dropdown menu's and displaying choice using JS -
once user chooses flavour want, want able display message on webpage choices have made drop-downs after submit button clicked. here have far:
<select name="flavour1" required> <option value="">please select flavour!</option> <option value="apple">apple</option> <option value="strawberry">strawberry</option> <option value="lemon">lemon</option> <option value="pear">pear</option> <option value="cola">cola</option> <option value="lime">lime</option> </select> <select name="flavour2" required> <option value="">please select flavour!</option> <option value="noflavour">no more flavours!</option> <option value="apple">apple</option> <option value="strawberry">strawberry</option> <option value="lemon">lemon</option> <option value="pear">pear</option> <option value="cola">cola</option> <option value="lime">lime</option> </select> <input type="submit" value="get flavour!!" onclick="getflavour()">
javascript attempt display message element id: "postflavour"
function getflavour(){ var flavour1 = getelementbyid("flavour1").value; var flavour2 = getelementbyid("flavour1").value; document.getelementbyid("postflavour").innerhtml = "congratulations, here chosen flavours: "+flavour1+", "+flavour2; }
function getflavour(){ var sel1 = getelementbyid("flavour1"); var sel2 = getelementbyid("flavour2"); var flavour1 = sel1.options[sel1.selectedindex]; var flavour2 = sel2.options[sel2.selectedindex]; document.getelementbyid("postflavour").innerhtml = "congratulation, here chosen flavours: "+flavour1+", "+flavour2; return false; }
Comments
Post a Comment