I have an HTML table with a “select_tag” field and I want to have another field that receives the option selected then multiply by another number for the price to display the total. Here is the table:
<table>
<tr>
<td>(select_tag)</td>
<td>price</td>
<td>total</td>
</tr>
</table>
How would I do this?
My answer is similar to @pythonFoo’s but I’ve assumed a static price and separated the JS from HTML:
HTML:
JavaScript (again, assumes the value in ‘price’ is constant and you’re just choosing ‘quantity’. If this isn’t the case, please clarify your question):
You would include the JavaScript in the
<head>tag of your page, under a<script type="text/javascript">tag.See a working example here: http://jsfiddle.net/andrewwhitaker/agepm/