PDA

View Full Version : Counter is not working


ksridhar69
10-04-2002, 06:06 PM
Here user enters the value in a1 say 50. Then he will enter the values in a2. If the values in a2 is greater than a1 user needs alert message only first time. But how to generate the alert only once


function checkvalue()
{
count = 0;
while(count < 1 )
{

if(parseInt(document.testform.a2.value) > parseInt(document.testform.a1.value))
{
alert ("please check the value");
}

}
count++;
}

<input type=text name=a1 value="50">

<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">
<input type=text name=a2 onChange="checkvalue()">

chrismiceli
10-04-2002, 06:45 PM
kind of see what you are saying, i think is what you need to make the alert come up only once

count = 0;

<input type="text" name="a1" onChange="checkvalue(), ++count">

now do this to your function

function checkvalue()
{
if (count <= 1 ) {
if(parseInt(document.testform.a2.value) > parseInt(document.testform.a1.value))
alert ("please check the value");
}
}