SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Prompting a User

    On entry to a page I need to prompt the user using an error message box / prompt window giving them some blurb and the option Yes or No.

    If they click Yes I'd like a page in a new window to open, if No is clicked then I would like a hidden form on the page to be submitted.

    Could anyone suggest the code to do this?

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
     window.onload = function()
     {
     	if (confirm('Question goes here?'))
     	{
     		 window.open('whatever.html', 'Whatever');
     	}
     	else
     	{
     		 formname.submit();
     	}
     }
    Or something along those lines.

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems so simple when you put it like that!

    Cheers

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dank4000
    Seems so simple when you put it like that!

    Cheers
    Glad I could help.

  5. #5
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript" language="JavaScript">
    window.onload = function()
     {
     	if (confirm('Are you a current EvaluteEnergy Subscriber?'))
     	{
     		 window.open('download.php', 'Download');
     	}
     	else
     	{
    
    <form name="order" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="upload" value="1">
    <input type="hidden" name="business" value ="user@dom.com">
    <input type="hidden" name="currency_code" value="GBP">
    <INPUT TYPE="hidden" NAME="item_number_1" VALUE="11">
    <INPUT TYPE="hidden" NAME="item_name_1" VALUE="2004 Results Analysis">
    <INPUT TYPE="hidden" NAME="amount_1" VALUE="50.00">
    
    </form>
    
     order.submit();
         }
     }
    
      </script>
    I'm using the above to prompt the user, however nothing is coming up currently.... anyone see any glaring errors?

    EDIT: Found the error, due to my complete n00bness to JS, obviously you declare the form before the js. Duh...
    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •