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>

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.