Jump to content

trying to make something simple. please help


mybluehair

Recommended Posts

I am trying to make a javascript code were when the user clicks a botton, it adds to the amount $myamount

here is what I have so far, but it completely dosn't work. (im new to javascript)

 

<FORM>

<INPUT TYPE="button" VALUE="CLICK!"

onClick="myAmount(1)">

</FORM>

<SCRIPT>

lastmod = document.lastModified   

lastmoddate = Date.parse(lastmod) 

if(lastmoddate == 0){             

  document.writeln("")

  } else {

  document.writeln("Last updated: " + lastmod)

}

</SCRIPT>

you just want the current value of a input field, plus some other amount? if so; do something like this:

 

<script language="javascript">
function getVal(what,myamount)
{
var what = document.getElementById('amount').value;
var total = (what*1) + (myamount*1);
document.getElementById('myval').innerHTML = total;
}
</script>

<form onsubmit="return false">
<input type="text" name="amount" id="amount">
<input type="button" onclick="getVal('amount','1')" value="Do The Math">
</form>

<br><br>

<span id="myval"></span>

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.