/    Sign up×
Community /Pin to ProfileBookmark

take value from edit box

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.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@pyroApr 03.2003 — Well, the simple way would be [color=darkblue](p1 - p2 -p3 > document.formname.MAX.value)[/color] 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.
Copy linkTweet thisAlerts:
@MikeOSApr 03.2003 — 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.
Copy linkTweet thisAlerts:
@swstosauthorApr 03.2003 — thanks
×

Success!

Help @swstos spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...