Question

I need help with this HTML with inline Javascript code. The question is how to pass the contents of a FORM SELECT FIELD element to a javascript function via another FORM FIELD?

<form name="bidForm" id="bidForm">
    Select your bid amount<br />
    <select name="newBid" id="newBid">
        <option value="88">88</option>
        <option value="99">99</option>
    </select>
    <input type="button" value="Place your Bid"
        onclick="alert(document.getElementById(newBid1).value);" />
</form>
Was it helpful?

Solution

You just have to pass in the ID properly, other than that what you are doing is fine:

<input type="button" value="Place your Bid"
    onclick="alert(document.getElementById('newBid').value);" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top