smerny Posted July 16, 2010 Share Posted July 16, 2010 Nothing is happening at all.Here is java script: <script type='text/javascript'> function calcperc() { //Declare and assign values var validNumbers = 'true'; var num = parseFloat(document.prosalform.outputnum.value); if(num.lenth < 1 || isNaN(num) || num < 5) { validNumbers = 'false'; } if (validNumbers == 'false') { document.forms['prosalform'].elements['outputperc'].value = '[NA]'; } else { //Calculate var result = num / 75000; //Change HTML document.forms['prosalform'].elements['outputperc'].value = result; } } </script> here are the relevant parts of html (within form name='prosalform'): Set Actual Salary: <input type='text' name='outputnum' id='outputnum' value='".$emp['current_salary']."' onkeyup='calcperc();' />...Set Percent Increase:<input type='text' name='outputperc' id='outputperc' value='0' onkeyup='calcnum();' /> will add 'calcnum()' after i get 'calcperc()' working Link to comment Share on other sites More sharing options...
wirehopper Posted July 16, 2010 Share Posted July 16, 2010 num.lenth is probably the problem. You might want to just remove it. Link to comment Share on other sites More sharing options...
MrFish Posted July 16, 2010 Share Posted July 16, 2010 if(num.lenth < 1 || isNaN(num) || num < 5) { validNumbers = 'false'; }Syntax error.Edit:A side note, true/false could be boolean values if you remove the quotations. It would be more efficient to compare booleans then to compare strings. I guess a fraction of a second isn't a big deal. It's just good to get into the habit in my opinion. Link to comment Share on other sites More sharing options...
smerny Posted July 16, 2010 Author Share Posted July 16, 2010 it is now:if(isNaN(num) || num < 5)and still nothing happens Link to comment Share on other sites More sharing options...
smerny Posted July 16, 2010 Author Share Posted July 16, 2010 okay... i found the problem and it was something you guys couldn't have seeni had the id of the form but forgot to "name" it Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.