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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2 forms 1 submit please help nothing works

    hello.
    ok my problem is that i have to submit 2 or more lines of text to my shopping cart. each line of text has its own form and you cant put more then one line in one form.
    please help me make this work

    <NOSCRIPT>This shopping-cart needs JavaScript. Please enable JavaScript in your browser's preferences.</NOSCRIPT>
    <script> if(typeof navigator.cookieEnabled=="boolean" && !navigator.cookieEnabled) alert("You need to enable Cookies in your browser, before this shopping-cart will work for you!"); </script>
    <!-- <script src=noper-language-pdt.utf8.js></script> -->
    <script src=http://www.mlpdecals.com/cgi/nopercart.js></script> <!-- nopERcart Shopping-Cart, from http://ereimer.net/nopercart.htm -->


    <FORM action="shoppingcart.htm" method=GET onSubmit="return AddToCart(this)">
    <font class=bigtext><b>Special Instructions:</b></font><br>
    <input type=text size=32 maxlength=200 name=USERTEXT> &nbsp;
    <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI">
    <input type=submit value="Add Instructions to Cart" class=bigbutton>
    </FORM>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Please use code tags when you post code.

    When you talk about form, are you talking about input elements?

    Also you should not be using the font tag, use a span.

    What is your exact problem?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need to be able the submit 5 of these forms with 1 submit button

    <FORM action="shoppingcart.htm" method=GET onSubmit="return AddToCart(this)">
    <font class=bigtext><b>Special Instructions:</b></font><br>
    <input type=text size=32 maxlength=200 name=USERTEXT> &nbsp;
    <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI">
    <input type=submit value="Add Instructions to Cart" class=bigbutton>
    </FORM>

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Quote Originally Posted by mlpdecals View Post
    hello.
    ok my problem is that i have to submit 2 or more lines of text to my shopping cart. each line of text has its own form and you cant put more then one line in one form.
    Uh?

    There is only one form. You cannot submit more than one form to the same site at the same time.

    Using JavaScript, you can make it so that when they click on the submit button, it will call a function that will submit all the forms. This works for IE. Not sure for any other browser.

    Code:
    <script type = "text/javascript">
    function submitallforms() {
    setTimeout('document.forms[0].submit()',100);
    setTimeout('document.forms[1].submit()',200);
    setTimeout('document.forms[2].submit()',300);
    }
    </script>
    Last edited by Philip M; 04-05-2010 at 09:26 AM.

  • #5
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok got that helps alot now my only question is how do i use only 1 button for more then 1 form

    (i know i only showed 1 form in my last posting i was trying to save space)

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Code:
    <input type = "button" onclick = "submitallforms()">

  • #7
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i got this for a code but it still doesnt seem to work. i know im not very good at this but im lost


    <NOSCRIPT>This shopping-cart needs JavaScript. Please enable JavaScript in your browser's preferences.</NOSCRIPT>
    <script> if(typeof navigator.cookieEnabled=="boolean" && !navigator.cookieEnabled) alert("You need to enable Cookies in your browser, before this shopping-cart will work for you!"); </script>
    <!-- <script src=noper-language-pdt.utf8.js></script> -->
    <script src=http://www.mlpdecals.com/cgi/nopercart.js></script>

    <script type = "text/javascript">
    function submitallforms() {
    setTimeout('document.forms[0].submit()',100);
    setTimeout('document.forms[1].submit()',200);
    setTimeout('document.forms[2].submit()',300);
    }
    </script>


    <FORM action="shoppingcart.htm" name=1 method=GET onSubmit="return AddToCart(this)">
    <font class=bigtext><b>Special Instructions:</b></font><br>
    <input type=text size=32 maxlength=200 name=USERTEXT> &nbsp;
    <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI">

    </FORM>
    <br><br>
    <FORM action="shoppingcart.htm" name=2 method=GET onSubmit="return AddToCart(this)">
    <font class=bigtext><b>Special Instructions:</b></font><br>
    <input type=text size=32 maxlength=200 name=USERTEXT> &nbsp;
    <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI">

    </FORM>
    <br><br>
    <FORM action="shoppingcart.htm" name="3" method=GET onSubmit="return AddToCart(this)">
    <font class=bigtext><b>Special Instructions:</b></font><br>
    <input type=text size=32 maxlength=200 name=USERTEXT> &nbsp;
    <input type=hidden _PRICE="0.00" _QUANTITY="1" _NAME="special-instructions" _ID="nSPCI">

    </FORM>

    <br>
    <input type=submit value="test" onclick = "submitallforms()">

  • #8
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    375
    Thanks
    9
    Thanked 55 Times in 54 Posts
    Hello,

    Seems that document.forms[i].submit() would always bypass AddToCart() function.

    Try create form-submission event, instead of direct one like above.
    This would enable your submission to be trapped by AddToCart():

    PHP Code:
    function submitallforms() {
      var
        
    ev document.createEvent("HTMLEvents");
      
    ev.initEvent("submit",true,true); //can bubble, cancellable form-submit event
      
    for (var i=0i<document.forms.lengthi++){ // Assuming all forms w/in your page to be submitted.
        
    document.forms[i].dispatchEvent(ev);
      }

    Hendra.


  •  

    Posting Permissions

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