/    Sign up×
Community /Pin to ProfileBookmark

Popup window to come up on error

Hello,

I know its long, but at least its easy to understand.

I have an if statement in a JavaScript that is working fine. It controls some parameters which go to a cgi script. The parameters of a text box (part number) get passed on to the script. The script removes spaces etc…, and basically gives out the details of what is being ordered (shaft size, connectin etc…, by reading substrings of the text box) This is working perfectly.

If the user types in an unexistant option, I can make it say “Not a valid option” in the shopping cart (cgi script) no problem, but then customer has to empty his cart and order again, annoying for him.

What I would like then is, if a wrong number is put in, how do I make a small window come up saying “Wrong number”, without it going to the cart. Then customer closes window and tries again.

Thanks is advance,

Patrick Blochle

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 12.2003 — something along these lines will work.

suppose you have a text field where user inputs a number

<input type="text" name="t1" onmouseup="return validate(this)"/>

now what you need to do in the validate function is that if the value is correct return true else return false.

If you have the some concept for the form to submit that if a function returns false then do not submit it and if its true then do submit,your problem will be solved.
Copy linkTweet thisAlerts:
@delldimensionauthorAug 12.2003 — I understand what you mean, but I already have the forms and bunch of stuff setup. And I'd rather have something like this:

I have this, and I would like the ****line to work...

...

...

...

if ( ((strnew.charAt(2))+(strnew.charAt(3)))=="12"){

shaftsize = "Shaft Size: 12 mmn";

}

else if ( ((strnew.charAt(2))+(strnew.charAt(3)))=="56"){

shaftsize = "Shaft Size: 5/16 inchn";

}

else {

shafsize = "Wrong number"; (this works but annoys customer as per previous post - will remove once have opoup)

******pop up window*******

}

...

...

...

I have many pages, and each one is very different from the other, char placements, options etc.... So I would like to modify it for each page separately.

I know there are many brackets, I am paranoid about such things. I also know they are unecessary at such a high quantity.

Thanks again,

Patrick Blochle
Copy linkTweet thisAlerts:
@Khalid_AliAug 12.2003 — Take a look at this changed version

else {

shafsize = "Wrong number"; (this works but annoys customer as per previous post - will remove once have opoup)

******pop up window*******

window.open("ErrorPage.html","errorWin","width300,height=200");

return false;//this line will stop the form from being submission.

}
×

Success!

Help @delldimension 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,
)...