bgmrk bgmrk - 1 year ago 65
Javascript Question

JavaScript help running a basic function on button click

Just trying to run a simple function when the button "calculate" is pressed. Function won't run at all when inputs are in a form, ultimately I want to be able to modify the other inputs when the calculate button is pressed. Any help at all please!

<html lang="en-US">
<script src=""></script>

<form name="form">
<input name="priceCAD" value="0"><br><br>
<input name="percentage" value="0"><br><br>
<input name="fiat" value="0"><br><br>
<input name="btc" value="0" maxlength="11"><br><br>

<input type="button" onClick="calculate()" name="calculate" value="Caculate" >
<input type="button" name="clear" value="Clear" onClick=", form.btc.value=0, form.markup.value=0">

<script type="text/javascript">
function calculate (){


Answer Source

Button HTML just need it:

<input type="button" onClick="calculate()" name="calculate" value="Caculate" >

And don't forget insert jquery lib in your <head>.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download