Hi. I’m hoping someone can point out my mistake, because I can’t seem to figure it out. (I’m sure it is something simple.) I trying to put together a very simple form that takes the selling price of a property and displays the commission amounts based on the plan. I got it to work no problem using PHP, but I wanted to use javascript so I didn’t have to reload the page.
The code I came up with is below, but I can’t seem to get it to work. It appears that the onclick is not calling the function, but I don’t see why not.
Thanks for any help.
<script type="javascript">
function agentchoice(form)
{
var price = (document.myform.inputbox.value);
var sanddollar = (price * .8) - 30;
document.myform.sanddollar.value = sanddollar;
var seashell = (price * .9) - 30 - 150;
document.myform.seashell.value = seashell;
var starfish = price - 150;
document.myform.starfish.value = starfish;
alert('starfish');
}
</script>
<form name="myform" action="">
<table>
<tr>
<td colspan="3">
<img src="images/agentchoice_logo.jpg" alt="Agent Choice Commision Calculator" />
</td>
</tr>
<tr>
<td>
<img src="images/Final_SandDollar2.jpg" alt="Sand Dollar Plan" />
</td>
<td>
<img src="images/Final_SeaShell2.jpg" alt="Seashell Plan" />
</td>
<td>
<img src="images/Final_StarFish2.jpg" alt="Star Fish Plan" />
</td>
</tr>
<tr>
<td class="commission">
Commission: <input type="text" name="sanddollar" />
</td>
<td class="commission">
Commission: <input type="text" name="seashell" />
</td>
<td class="commission">
Commission: <input type="text" name="starfish" />
</td>
</tr>
<tr>
<td colspan="3" style="padding:5px; text-align:right;">
Sale Price: <input type="text" name="inputbox">
<input type="button" name="button" value="Calculate" onclick="agentchoice(this.form)" />
</td>
</tr>
</table>
</form>