SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Two page JavaScript form

    I am making a registration form that users enter information on one page that I want to be able to take the entry information and put it into another page.

    Is this possible maybe with a popup?
    Any help and suggestions would be very helpful thanks.
    Wavelan

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why dont you just hide the second part of the form on the same page using css, that way people dont have to wait for the next page to load.

    like this quick example

    PHP Code:
    <script>
    function 
    switch1()
    {
        
    document.getElementById("textfield1").style.display='block';
        
    document.getElementById("textfield2").style.display='none';
        
    document.getElementById("textfield3").style.display='none';
    }

    function 
    switch2()
    {
        
    document.getElementById("textfield1").style.display='none';
        
    document.getElementById("textfield2").style.display='block';
        
    document.getElementById("textfield3").style.display='block';
    }
    </script>
    <form name="form1" method="get">
      <p> 
        <input type="text" id="textfield1" name="textfield" value="a">
        <input type="text" id="textfield2" name="textfield2" value="b" style="display:none">
        <input type="text" id="textfield3" name="textfield3" value="c" style="display:none"><br>
        <input type="submit" name="Submit" value="Submit">
      </p>
      
        <a href="javascript:switch1()">show a</a> | <a href="javascript:switch2()">show b</a>
      </form> 
    You can also do this with php as well.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh, yes it is posible to pass variables to popups. I just found and edited one of my old scripts for you.

    one thing, in the example the user can keep passing values to the popup box.

    PHP Code:
    <html>
    <
    head>
    <
    title>:)</title>
    <
    script>
    function 
    ViewWindow(opensizeWsizeHtextboxAtextboxB) {
        if (
    open == "true"//open is a switch (boolean)
        
    {    
            var 
    NewWindow window.open('',"process","width=" sizeW ", height=" sizeH ", , statusbar=0, menubar=0"); 

            
    with (NewWindow)
                {
                    
    with (document)
                        {
                            
    write("\n\n\n<html>\n");
                            
    write("<head>\n\n");
                                    
                            
    title "Image Name";

                            
    bgColor     =    "black";
                            
    fgColor     =    "red";
                            
    linkColor     =    "red";
                            
    alinkColor     =    "red";
                            
    vlinkColor     =    "red";
                        
                            
    write    ("<style>\n\n");
            
                            
    write    ("a:hover {\n");
                            
    write    ("color: 000000;\n");
                            
    write    ("background-color: #FFFFFF\n");
                            
    write    ("}\n\n");

                            
    write    ("color: #000000;\n");
                            
    write    ("background-color: #FFFFFF;\n");
                            
    write    ("cursor: default;\n");
                            
    write    ("}\n\n");
                        
                            
    write    ("</style>\n\n");
                            
                            
    write("</head>\n");
                            
    write("<body topmargin='0' leftmargin='0'>\n\n");
                            
    write ("<br>");
                            
    write ("textbox value 1 = " textboxA);
                            
    write ("<br>");
                            
    write ("textbox value 2 = " textboxB);
                            
                            
    write("</body>\n");
                            
    write("</html>\n\n\n");
                }
                
    focus();
            }
        }
        
        else
        {
            
    //alert (open)
        
    }
    }
    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <form name="form1" method="post" action="javascript:ViewWindow('true', 200, 200, document.form1.textfield.value, document.form1.textfield2.value)">
      <input type="text" name="textfield" value="a">
      <input type="text" name="textfield2" value="b">
      <input type="submit" name="Submit" value="Submit">
    </form>
    </body>
    </html> 
    hope it helps

  4. #4
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help I learned something from both your responses and figured out a way to do it that works best.

    Thanks again.
    Wavelan

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats good to hear

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Different approach

    Well maybe it's just me that thinks like this, but:

    You want to have two pages.

    Basically you want a form to pass it's information on to the next page, right?

    well then all you need is to change the form action a bit?

    On page 1 you use:
    form action="GET" target="_self" action="page2.html"

    this will mean when page 2 comes up, your location url will have ?field=value&... information in from the first form.

    You then want to send this second page to the server for processing, right?

    so you have your form tag for your handler:

    form action="post" target ="_self" id="form2" action="handler.php|cgi|pl|html|asp"

    and then you make Javascript handle the input to the action.

    window.onload="fnhand();"

    function fnhand(){
    var tref=top.self.location.href;
    if (tref.match(/?/){
    var fref=document.getElementById('form2');
    fref.action=fref.action+'?'+tref(/?/))[1];
    }
    }

    I haven't proofed this theory, but i think it's worth a go.
    alert the form2.action to check it's right afterwards.

    Hope this helps
    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •