How do you make it when they click submit it calls up a javascript to open a popup?

Discussion in 'Programming' started by NewTier, Feb 18, 2008.

  1. #1
    Please help me :)

    This is what I got:

    <script language="Javascript">
    Would this work somehow?
     
    NewTier, Feb 18, 2008 IP
  2. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I doubt that you need a separate function for each of those cases, but if it gets the job done...

    All you have to do to make it pop up a window when they click the submit button is to attach your function to either the form's onsubmit or the button's onclick event.
     
    The Critic, Feb 18, 2008 IP
  3. NewTier

    NewTier Notable Member

    Messages:
    2,201
    Likes Received:
    196
    Best Answers:
    0
    Trophy Points:
    250
    #3
    How do you do that?
     
    NewTier, Feb 18, 2008 IP
  4. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    On the form:

    
    <form onsubmit="popup3('http://www.megavideo.com/','megavideo',1100,786); window.focus(); SetCookie('pop11','1','3');">
    
    Code (markup):
    On the button:
    
    <input type="submit" onclick="popup3('http://www.megavideo.com/','megavideo',1100,786); window.focus(); SetCookie('pop11','1','3');">
    
    Code (markup):
    Actually, you should probably just put the focus() method and SetCookie function in your custom functions instead of calling them directly. It's just cleaner and to be honest I'm not sure window.focus() works the way you want it to when used like that.
     
    The Critic, Feb 19, 2008 IP
  5. NewTier

    NewTier Notable Member

    Messages:
    2,201
    Likes Received:
    196
    Best Answers:
    0
    Trophy Points:
    250
    #5
    I don't think it works. How do I make it so that when I click submit it'll just create a popup? :) Thanks..
     
    NewTier, Feb 19, 2008 IP
  6. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can break it down to the bare bones if you want. I didn't bother testing the other ones, so you may be right, but I tested both of these and they work just fine.


    
    <form onsubmit="window.open('http://www.megavideo.com/','megavideo','width=1100,height=786,scrollbars=yes,status=yes,resizable=yes, toolbar=yes,location=yes,menubar=yes,left=0,top=0'); SetCookie('pop11','1','3');">
    
    Code (markup):
    
    <input type="submit" onclick="window.open('http://www.megavideo.com/','megavideo','width=1100,height=786,scrollbars=yes,status=yes,resizable=yes, toolbar=yes,location=yes,menubar=yes,left=0,top=0'); SetCookie('pop11','1','3');">
    
    Code (markup):
     
    The Critic, Feb 20, 2008 IP