Jump to content

[SOLVED] Function to multiple a value by selected option in input field


twilitegxa

Recommended Posts

I need to know how to create a function that can multiply 10 by the value of the selected field in the option input field. Here is my form:

 

<form>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Level</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" value="Scout/Knight Attribute" size="19" name="attribute" />
</td>
<td>
<select name="attribute_level">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</td>
</tr>
</tbody>
</table>
<br />
</form>

I figured it out. :-)

 

function power()
{
var first,res1;
//Take the value of first textbox and convert it to float
first=parseFloat(document.forms[0].attribute_level.value);
res1=(first)*10;
//show the result in the result textbox
document.forms[0].power_points.value=res1;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.