Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Noblesville, IN
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using javascript to post a form and pop up a window.

    how can i have a form that, when click a button (or text link), the main form stays on the page submits the form in a popup window?

    the reason i'm doing this is because i have fields that a user fills in and i want to show in the popup what a fax is going to look like with the users fields filled in.

    thanks.
    Ed Ventura
    Graphic/Web Designer
    www.blackwatercompany.com

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try adding target="_blank" to the <form> tag or to the <a> tag to generate the "popup" window.

    Javascript isn't required for what you've described so far.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Location
    San Jose, CA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When you make your form, you need to assign an action that runs when the form is submitted. You can do this on the line that creates the Submit button or on the <form> line itself. If done on the submit button (which doesn't have to be called Submit, here I called it btnCalc), it'd look like this:

    <input name="btnCalc" type="button" value="Calculate" onClick="DoSomething()">

    When the button "Calculate" is clicked, the code in the function DoSomething() is run. This is JS code directly written in the HTML page or in its own .js file, it doesn't matter.

    function DoSomething()
    {
    var outW = window.open("", "newwin", "height=350, width=630");
    outW.document.write("<HTML>")
    outW.document.write("<TITLE>My Title Here</TITLE>")
    outW.document.write("<hr>blah blah blah<br><hr>");
    outW.document.write("</HTML>");
    }

    This opens a pop-up of a given size. The window is assigned to a variable outW and then that variable is used to write HTML code to the window. There are many other features you can add to the window.open() function. See any JS book for a description.

    Deb


  •  

    Posting Permissions

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