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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    popup on form submit

    I would like you to ask for a ltl bit assistance. Here is my problem:
    I have a form with few input lines and textarea, and after a form i have three buttons: [Close] [Preview] [Submit]
    And here is what i need:
    Then visitor click [Preview]- the forms data should be passed to pop_up window for preview (something like submited to pop up window) for example "pop_up_preview.php" but the main page should be left at it is (for editing data)

    But then user clicks [Submit], a forms data is passed to another regular page, for example "validate_data.php"

    Thank you in advance for assistance and i hope soon to see example how to deal with that
    And sorry for my poor english

  • #2
    New to the CF scene
    Join Date
    May 2006
    Location
    Pune
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hope this sample will help u

    Hello
    Designing is not do good but i think u can work with it
    Here is solution;contains to files first is for input and other used for preview the data.

    Input.htm
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <script language=Javascript defer>
    function showPreview(f)
    {
    //we don't want to count buttons so -3
    var str="";
    var c=f.length-3;
    var i;
    for(i=0;i<c;i++)
    {
    if(str!="")
    str+=";";
    str+=f.elements[i].value;
    }
    var x=showModalDialog('preview.htm',str,'status:no;resizable:yes');
    alert("Dialog result -"+x);
    }
    </script>
    </HEAD>
    <BODY>
    <form name="f" action="validation.php" method="post">
    Name <input type="text" name="t1">
    Phone <input type="text" name="t2">
    <input type="button" value="close" onclick="window.close();">
    <input type="button" value="preview" onclick="showPreview(this.form);">
    <input type="submit" value="submit">
    </BODY>
    </HTML>

    preview.htm
    <!-- This file is hardcoded because
    I am sure only 2 values are received by dialog -->

    <html>
    <script language=Javascript defer>
    function showPreview()
    {

    var values=dialogArguments.split(";")
    d1.innerHTML=values[0];
    d2.innerHTML=values[1];
    }
    </script>

    <body onload="showPreview();">
    <table cellpadding="5" aling="center">
    <tr>
    <td colspan="3" aling="center"><b>Data Preview</b></td>
    </tr>
    <tr>
    <td width="100">&nbsp;</td>
    <td>Name</td>
    <td><div id=d1></div></td>
    </tr>
    <tr>
    <td width="100">&nbsp;</td>
    <td>Pravin</td>
    <td><div id=d2></div></td>
    </tr>
    <tr>
    <td width="100">&nbsp;</td>
    <td><input type="button" onclick="returnValue=true;window.close();" value=" OK "></td>
    <td><input type="button" onclick="returnValue=false;window.close();" value=" Cancel "></td>
    </tr>
    </table>
    </body>
    </html>

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thank you, but i just (before 5 mins lol) have found howto do it simple:
    Code:
    <script>
    //pop-up window for preview
    function popup() {
    	win = window.open('','myWin','toolbars=0');
    	document.post.action='preview.php';
    	document.post.target='myWin';
    	document.post.submit();
    	document.post.action='validate.php';
    	document.post.target='_self';
    
    }
    </script>
    
    <form method="post" name="post" action="validate.php" target="_self" >";
    Name <input type="text" name="t1">
    Phone <input type="text" name="t2">
    <input type="button" name="post" class="submit" value="Preview" onclick="popup(); " /> <input type="submit" name="post" class="submit" value="Submit" />
    </form>
    pop ups code is simple and whatever you want, because he has access to post variables, i use php to take them

    But anyway, thank you!!!!
    Last edited by Lixas; 05-12-2006 at 01:02 PM.

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    button popupwindow solved



    Thanks Lixas this popupwindow problem I struggled for two days. But I solved from your article.

    regards

    Tanmoy (Web Devloper)

  • #5
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nice to hear that my post helped you to solve a problem. Good Luck

  • #6
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Happy New Year!
    Dear Lixus, could You publish the whole code of preview.php and validate.php too ("for dummies")?
    Very appreciate in forward, thanks.

  • #7
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi
    as you can see here i'm working with php, so the simplified example to get form's entries values is like this in both files (preview and validate)
    Simple like this
    PHP Code:
    <?php
    $formName 
    $_POST["t1"];
    $formPhone $_POST["t2"];

    #do whatever you want with the values....
    # example: check if phone meets your requires, does it look like the phone number and so on.... 
    ?>

  • #8
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for such a quick reply! I guess you spend all the time near computer :-)
    I uploaded my files on the server, but unfortunately no expected result appeared.
    The link is following: http://www.agondagoa.ru/preview/formPreview.php

    I created two files.

    formPreview.php

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Preview</title>
    </head>
    
    <body>
    <script>
    //pop-up window for preview
    function popup() {
    win = window.open('','myWin','toolbars=0');
    document.post.action='preview.php';
    document.post.target='myWin';
    document.post.submit();
    document.post.action='validate.php';
    document.post.target='_self';
    
    }
    </script>
    
    <form method="post" name="post" action="validate.php" target="_self" >
    Name <input type="text" name="t1">
    Phone <input type="text" name="t2">
    <input type="button" name="post" class="submit" value="Preview" onclick="popup(); " />
    <input type="submit" name="post" class="submit" value="Submit" />
    </form>
    </body>
    </html>
    preview.php with the code you mentioned above.

    The empty window is opening after push the button "Preview".
    I think some part of the code is missing. Could you please check it or send me a link with working example?

    Thanks a lot and sorry for stupid questions :-)

  • #9
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in your preview file try this:
    PHP Code:
    <?
    var_dump
    ($_POST);
    var_dump($_GET);
    ?>
    and you will see does your preview file receives data from form

  • #10
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried and got with filling in the word "test" in both input fields.
    Here is a result as I have seen in the new window:

    array(2) { ["t1"]=> string(4) "test" ["t2"]=> string(4) "test" } array(0) { }

    :-(

  • #11
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no need to be sad! it shows that this works your preview file received data from form, you just need to do something with this

    here is a simple example to output what you wrote in form:
    PHP Code:
    <?
    $formName 
    $_POST["t1"];
    $formPhone $_POST["t2"]; 

    echo 
    "Name: $formName";
    echo 
    "<br />"#new line
    echo "Phone: $formPhone";
    ?>
    Last edited by Lixas; 01-01-2010 at 12:05 PM. Reason: bug in code

  • #12
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are genius!
    Thanx a lot! I will send you then a link with a final result!
    Hmmm, should study PHP.... :-)

  • #13
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by Lixas View Post
    Thank you, but i just (before 5 mins lol) have found howto do it simple:
    Code:
    <script>
    //pop-up window for preview
    function popup() {
    	win = window.open('','myWin','toolbars=0');
    	document.post.action='preview.php';
    	document.post.target='myWin';
    	document.post.submit();
    	document.post.action='validate.php';
    	document.post.target='_self';
    
    }
    </script>
    
    <form method="post" name="post" action="validate.php" target="_self" >";
    Name <input type="text" name="t1">
    Phone <input type="text" name="t2">
    <input type="button" name="post" class="submit" value="Preview" onclick="popup(); " /> <input type="submit" name="post" class="submit" value="Submit" />
    </form>
    pop ups code is simple and whatever you want, because he has access to post variables, i use php to take them

    But anyway, thank you!!!!


    Hi lixas,
    thank you for your code above.. it solved my query on how to do a popup window upon clicking submit.
    one question though, how can i adjust the width and length of the popup window? and how can i add a "Close Window" button to the popup, which on click will refresh the parent page to display the home page instead.

    thanks a lot in advanced!

  • #14
    New Coder
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [QUOTE=xani;944082]one question though, how can i adjust the width and length of the popup window? and how can i add a "Close Window" button to the popup, which on click will refresh the parent page to display the home page instead./QUOTE]

    Code:
    win = window.open('','myWin','toolbars=0,width=200,height=100');
    Code:
    self.close ()
    http://forums.devarticles.com/showpo...35&postcount=2
    Last edited by Lixas; 04-14-2010 at 08:19 AM.

  • #15
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the size of the popup window is still the same i don't know if there is something wrong with my code...

    <script>
    //pop-up window
    function popup() {
    win = window.open(' ','myWin','toolbars=0,width=30,height=50');
    document.post.action='insert.php';
    document.post.target='myWin';
    document.post.submit();
    document.post.action='insert.php';
    document.post.target='_self';
    }
    </script>

    i copied the same code that you used for your preview and submit (above), though i just want to make the popup for the submit only. i am not sure if i should remove this already?

    document.post.submit();
    document.post.action='insert.php';

    thanks much. and sorry for the inconvenience..


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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