mybluehair Posted January 6, 2008 Share Posted January 6, 2008 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> Link to comment https://forums.phpfreaks.com/topic/84778-trying-to-make-something-simple-please-help/ Share on other sites More sharing options...
phpQuestioner Posted January 6, 2008 Share Posted January 6, 2008 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> Link to comment https://forums.phpfreaks.com/topic/84778-trying-to-make-something-simple-please-help/#findComment-432113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.