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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Location
    lansing, michigan
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form confirm won't work with tables

    While creating an online ordering site for some of our customers, I wanted a order confirmation box to pop up when Submit was clicked, and show the user the items and quantities he had ordered, with options of Submit or Go Back to the order page. I glommed the script below from js-examples.com, but it doesn't work if the form is formatted with tables, as mine is. (I haven't figured out css positioning well enough yet to get rid of them.) The dialog box pops up, but none of the user selections are shown in it. The script works fine if I remove the <table> tag. Can anyone point me in the right direction? Thanks in advance.

    Steve












    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <!--
    This file retrieved from the JS-Examples archives
    http://www.js-examples.com
    100s of free ready to use scripts, tutorials, forums.
    Author: JS-Examples - http://www.js-examples.com/
    -->



    </head>
    <body>

    <SCRIPT>
    function validateForm(_f) {
    var _b="Here is the form data you entered:";
    var _l="Do you want to submit this data?";
    var _n="\n";
    var _t="\t";
    var _s="";

    for(var _obj = _f.firstChild; _obj ; _obj=_obj.nextSibling)
    {
    if(_obj.name!=undefined)
    {
    /*
    * Pick up the title if it exists - otherwise use the name of the object.
    */
    if(!_obj.header)_obj.header=_obj.name;

    /*
    * Deal with Text and Hidden and TextArea
    */
    if(_obj.type=="text" || _obj.type=="hidden" || _obj.type=="textarea")
    _s+=_obj.header+_t+_obj.value+_n;
    /*
    * Deal with Radio Buttons, and Checkboxes
    */
    if((_obj.type=="radio"||_obj.type=="checkbox")&&_obj.checked)
    {
    _s+=_obj.header+_t+_obj.value+_n;
    }
    /*
    * Deal with Select Boxes
    */
    var _regExp=/select/i;
    if(_obj.type.match(_regExp))
    _s+=_obj.header+_t+_obj.value+_n;
    }
    }

    return confirm(_b+_n+_n+_s+_n+_l);
    }
    </SCRIPT>

    <FORM name=f1 onsubmit="return validateForm(document.f1)">
    <table class="ordermain" cellspacing="18">
    <tr><td><input type=text name="Andes Gold" size="2" maxlength="2">Andes Gold</td><td><input type=text name="Best Blend" size=2 maxlength=2>Best Blend</td><td><input type=text name="Black & Tan" size=2 maxlength=2>Black & Tan</td></tr>
    <tr><td><input type=text name="Community Blend" size=2 maxlength=2>Community Blend</td><td><input type=text name="Creme Brulee" size=2 maxlength=2>Creme Brulee</td><td><input type=text name="English Toffee" size=2 maxlength=2>English Toffee</td></tr>
    <tr><td><input type=text name="Espresso" size=2 maxlength=2>Espresso Roast</td><td><input type=text name="French Roast" size=2 maxlength=2>French Roast</td><td><input type=text name="French Roast w/Vanilla" size=2 maxlength=2>French Roast w/Vanilla</td></tr>
    <tr><td><input type=text name="Hazelnut Cream" size=2 maxlength=2>Hazelnut Cream</td><td><input type=text name="Irish Cream" size=2 maxlength=2>Irish Cream</td><td><input type=text name="Java Estate" size=2 maxlength=2>Java Estate</td></tr>
    <tr><td><input type=text name="Mich Sweet Cherry" size=2 maxlength=2>Mich Sweet Cherry</td><td><input type=text name="Mocha Java" size=2 maxlength=2>Mocha Java</td><td><input type=text name="Out Of Africa" size=2 maxlength=2>Out Of Africa</td></tr>
    <tr><td><input type=text name="Sumatra" size=2 maxlength=2>Sumatra</td><td><input type=text name="Tanzania" size=2 maxlength=2>Tanzania</td></tr>
    </table>
    <input type="submit" value="Send This Order">
    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try closing the FORM tag.

    ...
    ...
    </table>
    <input type="submit" value="Send This Order">
    </FORM>
    </body>
    </html>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ste...
    n' /me just a noticed® tooo errr three???lol...
    most of your tr's have just a three® td's in 'em...
    'cept for this one...
    Code:
    <tr><td><input type=text name="Sumatra" size=2
                             maxlength=2>Sumatra</td><td><input type=text name="Tanzania" size=2
                             maxlength=2>Tanzania</td></tr>
    in one of 'em??? you should have just a colspan="2"®

    n' like alg said...just a close® your </form> :O)))
    The New JustaBuster Version 2.0 OR JustaBusta Lite V2.0
    ...just a special® thanx kinda hugs to jkd n' nex ...:O)))

    CommemorateWTC.com --Please lend your support

  • #4
    New to the CF scene
    Join Date
    Aug 2002
    Location
    lansing, michigan
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    still doesn't seem to work

    Oops - I think I closed the <form> tag in the original, but left it out of my first post. I put it back in and got the same result - box appears, but no form data. Thanks for your input, though.

    Steve


  •  

    Posting Permissions

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