Jump to content

Form input-calc-change


smerny

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...