www.webdeveloper.com
Results 1 to 4 of 4

Thread: external var

  1. #1
    Join Date
    Dec 2008
    Posts
    33

    external var

    //-----10% Off Coupon-----
    if (coupon=="N110"){
    form.PRICE.value=-(moneyFormat(fTotal * .10)-1);
    form.ID_NUM.value="N110";
    form.NAME.value=" Craft Month Promo 10% Off";
    location.href=location.href;
    return true;
    }

    I want to replace the .10 with an external peice of data, so users can change the amount with having to open the script. Sorta like those early marquees' where the marquee text was inserted from a text file.


    Tom Rector

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    http://www.webdeveloper.com/forum/sh...16&postcount=3

    You did not include the function name, so I'll have to use arbitrary replacements:

    Code:
    function calcDiscount(coupon,disc){
    if (coupon=="N110"){
    form.PRICE.value=(moneyFormat(fTotal * disc)-1);
    form.ID_NUM.value=coupon;
    form.NAME.value=" Craft Month Promo 10% Off";
    location.href=location.href;
    return true;
    }
    }

  3. #3
    Join Date
    Dec 2008
    Posts
    33

    Thanks

    I haven't tried it yet, need to figure out how to get "disc" value into .js from the external file.

    Same as with this: I need to replace "name" in script below with data from a perl script result.
    "../../cgi-bin/BCssi.cgi?MealDate=TODAY" returns "YES" or "NO" when used direct.


    <script>
    var name = "../../cgi-bin/BCssi.cgi?MealDate=TODAY"
    if (name = "Yes") {
    document.write("<iframe name='I41' src='../../cgi-bin/BCspecial.pl?MealDate=TODAY' allowtransparency='true' frameborder='0' width='300' height='136'> ")
    }
    else {
    document.write("<iframe name='I41' src='OutOfStock.htm' allowtransparency='true' frameborder='0' width='300' height='136'> ")
    }
    </script>

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    You pass it when you call the function.

    onclick = "calcDiscount('N110',.5);" passes 'N110' as the coupon name, and .5 as the discount.

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles