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 12 of 12
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Function not working

    Hello, I am new to this forum stuff so please bear with me.
    This is the code I am using.
    Code:
    <script type="text/javascript">
    	function ReadForm(obj1) {
            "use strict";
    		var amt = obj1.amount.value;
    		obj1.amount.value = amt - (amt / 6.6);
    	}
    </script>
    The value (obj1) is 99
    It is supposed to return a value of 84 and I keep getting 99
    DId I do something wrong ?
    Last edited by ChadXSO; 05-06-2012 at 05:38 PM.

  • #2
    New Coder
    Join Date
    Mar 2012
    Location
    US
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a reason you have 2 <script type="text/javascript">s in your code and only one </script>?

  • #3
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry about that. It was left over form a previous paste.

  • #4
    New Coder
    Join Date
    Mar 2012
    Location
    US
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay. Can you put up a little more of your code?

  • #5
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is some more code (please do not mind the ATROCIOUS indentation. I was up until 3:30am)
    [CODE]

    <div id="apDiv4">
    <form method="post" action="https://www.paypal.com/us/cgi-bin/webscr" target="paypal" onsubmit="Return ReadForm(this);">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="add" value="1">
    <input type="hidden" name="business" value="cassie@hornbrook.com">
    <input type="hidden" name="item_name" value="Veneer Provisionalization">
    <input type="hidden" name="item_number" value="DVD-VP">
    <input type="hidden" name="amount" value="99">
    <input type="hidden" name="quantity" value="1">
    <input type="hidden" name="no_shipping" value="2">
    <input type="hidden" name="shopping_url" value="http://www.davidhornbrook.com/Dvds.html">
    <input type="hidden" name="return" value="http://www.davidhornbrook.com/Dvds.html">
    <input type="hidden" name="notify_url" value="http://www.davidhornbrook.com/Dvds.html">

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;DVD#:1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input value="Discount Code:" name="on0" type="hidden">Discount Code:&nbsp;<input name="coupon_code" size="6" maxlength="7" type="text" value="">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Price: 99.00<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="image" border="0" alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_cart_SM.gif" />
    <img width="1" height="1" border="0" src="https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/i/scr/pixel.gif" alt="" />
    </form>
    </div>
    [CODE]
    Also, the site you can go to is www.davidhornbrook.com/Dvds2.html
    This is where I am trying to get it to work. The Dvds.html page works with an external php file on a different server. I am trying to make this more efficient.
    Thanks for your quick responses too.

  • #6
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    878
    Thanks
    0
    Thanked 114 Times in 113 Posts
    the problem is this line:
    Code:
     "use strict";
    if it is an attempt to make a comment,
    The it must be
    Code:
    // "use strict";
    .

    As it is now you ask the script to execute a string.

    you can assign a string to a variable: command="use strict";
    write it to screen: document.write("use strict");
    pass it to a function as a parameter: Myfunction("use strict");
    use it in a comparison: if (Mytext==""use strict"){Text=='"Good'}; and so on , but you can't execute it.

    this line does that the function will be seen as undefined, thus it can't be executed

  • #7
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the input. I only put that line there because I thought it may help?
    I have tried it without that line and I still have the same problem.

  • #8
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    878
    Thanks
    0
    Thanked 114 Times in 113 Posts
    you also have
    Code:
    onsubmit="Return ReadForm(this);">
    in your form.
    It must be
    Code:
    onsubmit="return ReadForm(this);">

  • Users who have thanked Lerura for this post:

    ChadXSO (05-06-2012)

  • #9
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I cannot believe that I missed the capitalization on that!!
    Thank you so much for that. It appears to be working fine now.
    I guess working that late my eyes missed it. Great catch

  • #10
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It works the first time I Add to cart. However, when I return to the Dvds2 page and click add to cart I get this error "The link you have used to enter the PayPal system contains an incorrectly formatted item amount."
    Even though it worked the first time I added to cart.
    If I refresh the page it works fine.
    Any ideas?

  • #11
    New Coder
    Join Date
    Mar 2012
    Location
    US
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <body onload="location.reload(true)"> will immediately refresh the page once it loads. Is that what you're looking for?

  • #12
    New to the CF scene
    Join Date
    May 2012
    Location
    USA
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I will give that a try, bit I think it may be something more. What happens is I can add 1 dvd to the cart with no problem. I close the paypal window and add another dvd to the cart (with a discount code this time) and that works no problem.
    When I close that paypal window and add another dvd with no discount code, I get the error. So I think it has to do with reloading the page after they do something on it, not when it loads. Like refresh it after they press a button.


  •  

    Tags for this Thread

    Posting Permissions

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