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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2004
    Location
    california
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    submit form won't work#$@!

    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
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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(f) {
     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(this.form)">
    Last edited by glenngv; 02-10-2004 at 06:03 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Feb 2004
    Location
    california
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Feb 2004
    Location
    california
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can put back the other forms I removed. I just showed you the basic working code for clarity.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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