/    Sign up×
Community /Pin to ProfileBookmark

Javascript statements

?
Hello, I have a small java script problem regarding printing an alert to screen when a calculated number is of a certain value.

I would like the web page to alert the user with one alert then the number is over 25
One alert when the value is below 25 but more than 10
And one when the value is below 10.

How can I do this?
This is what I have so far:

[QUOTE]

function doSum(a,b)
{
var total=parseInt(a)+parseInt(b);
document.form1.sum.value=total;
if (total >25)
{
alert(“wow that’s a big total”);
}
if (total <25)
{
alert(“coor, that total isn’t too large now is it?!!”);
}
else (total <10)
{
alert(“wow, this number is tiny!”);
}
}

[/QUOTE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 19.2007 — function doSum(a,b) {
var total=parseInt(a)+parseInt(b);
document.form1.sum.value=total;
if (total &gt;25) {
alert("wow that's a big total");
}
else if (total &lt;10) {
alert("wow, this number is tiny!");
}
else {
alert("coor, that total isn't too large now is it?!!");
}
}
Copy linkTweet thisAlerts:
@KorNov 19.2007 — and:

var total=parseInt(a,[COLOR="Blue"]10[/COLOR])+parseInt(b,[COLOR="Blue"]10[/COLOR]);

to avoid possible surprises (ie: a='08')
Copy linkTweet thisAlerts:
@talksrauthorNov 20.2007 — Thank you for the two posts, they are very helpful.

?
×

Success!

Help @talksr 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 6.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...