Web Analytics Made Easy -
StatCounter submit form won't work#$@! - CodingForum

Announcement

Collapse
No announcement yet.

submit form won't work#[email protected]!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • submit form won't work#[email protected]!

    script below won't work when submit click.
    Don't know what is the problem, can someone fix this for me?

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    <HTML><HEAD><TITLE>Widgets Shopping cart</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide script
    function useCCDollars() {

    var i=20.00;

    percentOfDollars = document.CCDollars.CustomClubsBox.options[document.CCDollars.CustomClubsBox.selectedIndex].value;
    // alert(document.CCDollars.CustomClubsBox.options[document.CCDollars.CustomClubsBox.selectedIndex].value);


    document.CCDollars.displayBox.value= percentOfDollars=i*percentOfDollars;


    var nPrice = eval(document.CCDollars.displayBox.value);
    document.CCDollars.newPrice.value = (20 - nPrice);

    }
    // End script hiding -->
    </SCRIPT>

    </HEAD><BODY BGCOLOR="DDDDFF">

    <FORM NAME="CCDollars">
    <TABLE ALIGN="right"><TR><TD><B>I would like to get a discount of</B>

    <SELECT NAME="CustomClubsBox">
    <OPTION VALUE="0">0%</option>
    <OPTION VALUE="0.10">10%</option>
    <OPTION VALUE="0.15">15% for 40</option>
    <OPTION VALUE="0.20">20% for 50</option>
    <OPTION VALUE="0.25">25% for 60</option>
    </SELECT>

    <B>certificates</B></TD></TR> <TR><TD><B>Which is $</B>
    <INPUT TYPE="text" NAME="displayBox" VALUE="0" SIZE=5 MAXLENGTH=5> (savings)</TD></TR> <TR><TD><B>Making my new price</B><BR><B>$</B>
    <INPUT TYPE="text" NAME="newPrice" VALUE="20.00" select style="color: #ffffce; background-color:#08007b; font-weight:bold"> </TD></TR> <TR><TD>


    <INPUT TYPE="button" NAME="changer" VALUE=">>> click" ONCLICK="useCCDollars()"></TD></TR>
    </FORM>



    <form action="http://www.shoppingcart.com/sc/cart.cgi" method=POST>
    <INPUT TYPE="hidden" name="item" VALUE="1234my account^certificate.^copy sheet^op1^1^^^ea.^^">
    <INPUT TYPE="hidden" NAME="sitenum" VALUE="19">
    <INPUT TYPE="hidden" NAME="location" VALUE="clubs">
    <INPUT TYPE="hidden" NAME="doit" VALUE="doit">
    <TR><TD ALIGN="right"><FONT COLOR="0000FF"><B>Return to last Item</B></FONT></TD>
    <TD WIDTH="15%">
    <INPUT TYPE="submit" NAME="goBack" VALUE="<<<">
    </TD></TR>
    </FORM>
    <FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
    <INPUT TYPE="hidden" NAME="sitenum" VALUE="19">
    <INPUT TYPE="hidden" NAME="location" VALUE="clubs">
    <INPUT TYPE="hidden" NAME="doit" VALUE="doit"> <INPUT TYPE="hidden" NAME="VC" VALUE=">>>"> <TR><TD ALIGN="right"><FONT COLOR="0000FF"><B>Make This Purchase</B></FONT></TD> <TD WIDTH="15%"><input align=center type=image border=0 name=add
    src="bluo-addsm.gif" width=100 height=34></TD></TR>
    </FORM>
    </TABLE>
    </body>
    </html>

  • #2
    What's the equal sign doing in there?

    document.CCDollars.displayBox.value= percentOfDollars=i*percentOfDollars;

    Typo? Probably you want a minus sign.

    And you should not use eval to typecast an input to number (although it works). Search this forum for eval and you'll get what I mean.

    var nPrice = parseInt(document.CCDollars.displayBox.value, 10);
    or:
    var nPrice = Number(document.CCDollars.displayBox.value);

    but you will use it for subtraction so typecasting is not needed anymore. Only in addition (+) you need to typecast since + also means string concatenation.

    Here is the final code:
    Code:
    function useCCDollars([b]f[/b]) {
     var i=20.00; 
     percentOfDollars = f.CustomClubsBox.options[f.CustomClubsBox.selectedIndex].value;
     f.displayBox.value = percentOfDollars - i*percentOfDollars;
     f.newPrice.value = 20 - f.displayBox.value;
    }
    ...
    <input type="button" name="changer" value=">>> click" onclick="useCCDollars([b]this.form[/b])">
    Last edited by glenngv; Feb 10, 2004, 12:03 AM.
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      Thanks Glen,

      I tried but this time percentage value discount cost
      seems disabled as it was working before. When
      click to get the amount of dollar discount it reamains
      to be at a halt!

      On top of that, still lies the problem originally that is submit
      is disabled!

      Wonder if you can show me the full script that way I am not missing out anything. I am just a novice and not too good at
      script problem solving.

      thanks

      Comment


      • #4
        I removed unrelated items.

        Code:
        <html>
        <head>
        <script type="text/javascript">
        function useCCDollars(f) {
         var i=20.00; 
         percentOfDollars = f.CustomClubsBox.options[f.CustomClubsBox.selectedIndex].value;
         f.displayBox.value = (percentOfDollars - i*percentOfDollars).toFixed(2);
         f.newPrice.value = (20 - f.displayBox.value).toFixed(2);
        }
        
        </script>
        </head>
        <body>
        <FORM NAME="CCDollars">
        <B>I would like to get a discount of</B> 
        
        <SELECT NAME="CustomClubsBox">
        <OPTION VALUE="0">0%</option>
        <OPTION VALUE="0.10">10%</option>
        <OPTION VALUE="0.15">15% for 40</option>
        <OPTION VALUE="0.20">20% for 50</option>
        <OPTION VALUE="0.25">25% for 60</option>
        </SELECT>
        
        <B>certificates</B><br>
        <B>Which is $</B> 
        <INPUT TYPE="text" NAME="displayBox" VALUE="0" SIZE=5 MAXLENGTH=5> (savings)<br>
        <B>Making my new price</B><BR><B>$</B> 
        <INPUT TYPE="text" NAME="newPrice" VALUE="20.00" select style="color: #ffffce; background-color:#08007b; 
        
        font-weight:bold">
        <p><INPUT TYPE="button" NAME="changer" VALUE=">>> click" ONCLICK="useCCDollars(this.form)"></p> 
        </FORM> 
        </body>
        </html>
        If the problem persists, it's better you post a link to your page.
        Glenn
        vBulletin Mods That Rock!

        Comment


        • #5
          I see what you mean by that minus and seems to work
          well. Since you deleted the forwarding shopping cart url
          from my original post, how can a visitor submit this?

          The one that was deleted was "making the purchase"
          and click activation.

          thanks

          Comment


          • #6
            You can put back the other forms I removed. I just showed you the basic working code for clarity.
            Glenn
            vBulletin Mods That Rock!

            Comment

            Working...
            X