If the data could then be saved and I could everyso often dump it into a database.
That's not possible with Javascript. The most that can be done is to submit the values to a server-side script that can handle them.
Code:
<form action="dbsave.asp" method="post">
<fieldset>
<legend>Ordering Form</legend>
<select onchange="this.form.elements['tprice'].value = parseInt(this.form.elements['qty'].value) * parseFloat(this.value);">
<option value="35.99">A bed</option>
<option value="12.99">A very small chair</option>
</select>
<br>
Quantity: <input type="text" size="1" name="qty">
<br>
Total price:
<input
type="text"
size="4"
name="tprice"
style="
background-color: transparent;
border: 0px none;
"
readonly="readonly"
>
<input type="submit" value="Save">
</fieldset>
</form>
Note that the values generated by this script can be edited by the user, and so should not be relied on for anything other than to give the user information.
Bookmarks