Click to See Complete Forum and Search --> : take value from edit box


swstos
04-03-2003, 05:25 PM
else if ( ( p1 - p2 - p3 < 0 ) || ( p1 - p2 -p3 > 100 ) )
alert("point out of range.");

the above code is part of a javascript and checks if the value is between 0 and 100.

I need to changed to something like

else if ( ( p1 - p2 - p3 < 0 ) || ( p1 - p2 -p3 > value of the edit box with the name MAX ) )
alert("point out of range.");

thats because the value in the edit box with the name MAX can be changed

Can anyone please tell me how can i do it ?

Thanks in advance.

pyro
04-03-2003, 05:49 PM
Well, the simple way would be (p1 - p2 -p3 > document.formname.MAX.value) but, you may want to also make sure that the MAX field only contains numbers. Otherwise you script is going to cause problems if they type some text into the MAX field.

MikeOS
04-03-2003, 05:51 PM
You need to enter the path to the text box. For instance:

else if ( ( p1 - p2 - p3 < 0 ) || ( p1 - p2 -p3 > parseInt(document.formname.MAX.value)) )

This part:
parseInt(document.formname.MAX.value)

Takes the value in the textbox and converts it to a number, as all form entries begin life as strings. You need to alter the path to your form accordingly.

So you should change the part: document.formname.MAX.value

You said the form control was called MAX, if so then all you need to change is the formname part to the name you have given your form.

swstos
04-03-2003, 05:57 PM
thanks