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> Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.