6 Replies - 1999 Views - Last Post: 23 August 2012 - 02:11 PM

#1 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

popup dialog

Posted 22 August 2012 - 12:06 PM

Hi guys, quick question. I know how to do simple dialogs with javascript or JQuery, but I am trying to do something slightly different here. I have a form, which is hooked up to some third party system, therefore some of the fields are mandatory. A couple of these fields
<INPUT TYPE="hidden" NAME="onfailure" VALUE="http://www.one.com">
<INPUT TYPE="hidden" NAME="onsuccess" VALUE="http://www.two.com">

Redirect to either a success page, or a non successful page. Before this redirect, I want to display a popup dialog for both of these. If I place an onsubmit on my form which calls a javascript method, how would I get it to know whether to call the successful or unsuccessful dialog?

Cheers

Nick

Is This A Good Question/Topic? 0
  • +

Replies To: popup dialog

#2 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: popup dialog

Posted 22 August 2012 - 10:15 PM

I don't really get what you mean when you said "I want to display a popup for both of these".
Does the chooser decide what page he/she will go to?

Some quick tips:
- the confirm popup can return a boolean(call the popup, in a method make the return value of the popup the parameter)
Example:
<html>
<head>
<script type="text/javascript">
function doYouWanna(choice){
	if (choice==true){
		alert("You want to, huh.");
	} else {
		alert("You don't want to? Who cares!");
	}
}
</script>
</head>
<body>
<input type="button" value="What?" onclick="doYouWanna(confirm('You want to or not?'))"/>
</body>
</html>


- the prompt popup can return a value(though I guess this isn't what you're looking for)
Was This Post Helpful? 1
  • +
  • -

#3 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: popup dialog

Posted 23 August 2012 - 01:49 AM

Thanks for the reply. What actually happens is that if the system I am communicating with returns a success code, the following is called and the page is redirected to two.com
<INPUT TYPE="hidden" NAME="onsuccess" VALUE="http://www.two.com">


If the system returns a failure code, the following is called and the page redirected to one.com
<INPUT TYPE="hidden" NAME="onfailure" VALUE="http://www.one.com">



So in essense, I am after something along the lines of the following.
<html>
<head>
<script type="text/javascript">
function doYouWanna(name){
	if (name==onsuccess){
		alert("Successful information inputed");
	} else {
		alert("Please try again, wrong information inputted!");
	}
}
</script>
</head>
<body>
<input type="button" value="What?" onclick="doYouWanna(alert(NAME))"/> //Where name is the value of the field onsuccess or onfailure
</body>
</html>


So depending on what hidden input is triggered, I need an alert box to display according to that value. Hope this is clearer?

Cheers

Nick
Was This Post Helpful? 0
  • +
  • -

#4 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: popup dialog

Posted 23 August 2012 - 12:06 PM

View Postnick2price, on 23 August 2012 - 01:49 AM, said:

Thanks for the reply. What actually happens is that if the system I am communicating with returns a success code, the following is called and the page is redirected to two.com
<INPUT TYPE="hidden" NAME="onsuccess" VALUE="http://www.two.com">


If the system returns a failure code, the following is called and the page redirected to one.com
<INPUT TYPE="hidden" NAME="onfailure" VALUE="http://www.one.com">



So in essense, I am after something along the lines of the following.
<html>
<head>
<script type="text/javascript">
function doYouWanna(name){
	if (name==onsuccess){
		alert("Successful information inputed");
	} else {
		alert("Please try again, wrong information inputted!");
	}
}
</script>
</head>
<body>
<input type="button" value="What?" onclick="doYouWanna(alert(NAME))"/> //Where name is the value of the field onsuccess or onfailure
</body>
</html>


So depending on what hidden input is triggered, I need an alert box to display according to that value. Hope this is clearer?

Cheers

Nick


Are the pages that the user are redirected to, to tell the user that they haven't filled in some information, or to filter out users who have chosen certain information (like when I get filtered out of Google surveys for being too young :nottalkingtoyou: )?

If it's the first, then you could just check the value of the boxes (or compare them to "" to see if they're filled in) and then show an alert.

If it's the second, then you can do the same thing.

Else, you need to explain a bit more :innocent:

(See what I did there? If, if, else? Yeh? Ahh, never mind...)
Was This Post Helpful? 1
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: popup dialog

Posted 23 August 2012 - 12:13 PM

If you have fields that are required, you should check them BEFORE you submit them. One good way to do this, using jQuery, is the validity plugin.
Was This Post Helpful? 1
  • +
  • -

#6 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: popup dialog

Posted 23 August 2012 - 02:00 PM

The validation is beyond my control (to some sense) as this is controlled by the third party system. Basically, I have a form, and this form has all the mandatory fields required by the third party system (some hidden, some not). Both the onsuccess and onfailure are mandatory, so even if I do validate before submit is pressed, I still need to have both of these in my form for the third party software to check. So when the user enters information and clicks submit on my form, all this information is sent to this third party server. The server then somehow redirects to either of these
<INPUT TYPE="hidden" NAME="onsuccess" VALUE="http://www.two.com">
<INPUT TYPE="hidden" NAME="onfailure" VALUE="http://www.one.com">


Now on my real form, I use the same url for both of the above fields. So to determine whether the action was successful or not, I need to display a pop up box. So essentially, if onsuccess is activated, I display a success dialog, and vice versa. I know that the server returns a variable result which holds a number to determine whether the action was succesful or not. Can I use this variable to display the correct popup?

But the important thing to note from what I have said, I dont handle the validation, the third party does. I only receive a result from their validation telling me if it was successful or not.

Cheers

Nick
Was This Post Helpful? 0
  • +
  • -

#7 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: popup dialog

Posted 23 August 2012 - 02:11 PM

View Postnick2price, on 23 August 2012 - 02:00 PM, said:

The validation is beyond my control (to some sense) as this is controlled by the third party system. Basically, I have a form, and this form has all the mandatory fields required by the third party system (some hidden, some not). Both the onsuccess and onfailure are mandatory, so even if I do validate before submit is pressed, I still need to have both of these in my form for the third party software to check. So when the user enters information and clicks submit on my form, all this information is sent to this third party server. The server then somehow redirects to either of these
<INPUT TYPE="hidden" NAME="onsuccess" VALUE="http://www.two.com">
<INPUT TYPE="hidden" NAME="onfailure" VALUE="http://www.one.com">


Now on my real form, I use the same url for both of the above fields. So to determine whether the action was successful or not, I need to display a pop up box. So essentially, if onsuccess is activated, I display a success dialog, and vice versa. I know that the server returns a variable result which holds a number to determine whether the action was succesful or not. Can I use this variable to display the correct popup?

But the important thing to note from what I have said, I dont handle the validation, the third party does. I only receive a result from their validation telling me if it was successful or not.

Cheers

Nick


Oh, in that case then you'll need to do a little testing and attach an alert to the result - that way you can simply show yourself what data comes back from a valid and invalid result. Then you can work upon creating a proper message.

For the proper popup, I recommend using jQuery UI's dialog:
http://jqueryui.com/
http://jqueryui.com/demos/dialog/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1