KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Javascript functions with 4DBK
PRODUCT: 4D Business Kit | VERSION: 2003 | PLATFORM: Mac & Win
Published On: February 5, 2003

When you are designing your store front, you will most definitely run into the need for JavaScript functions. Although they can become very useful, at times they can clutter up your webpage. To keep things nice and neat, you can create the functions in a simple text file with a ".js" extension (a JavaScript library, if you will) and reference this file from within the html document. This will not only keep the html file organized, but will allow you to organize your JavaScript functions as well.

Here is an example of a JavaScript function located on an html page:

< script type="text/javascript" >
<!--
function add_to_cart(form)
{
var ccode=ToUpperCase(form.productid.value);
var cmd;
cmd="4DBKExecute:4DBKStoreSet/MYST;";
cmd=cmd+"4DBKQuantitySet/=1;";
cmd=cmd+"4DBKBasketSet/"+ccode+";";
cmd=cmd+"4DBKGo/shoppingcart.html";
window.top.location=EncodeURL(cmd);
}
//-->
</script>

Here is that same JavaScript function in a file called Myscripts.js, referenced by a script tag:

<script type="text/javascript" src="/MYST_Site/Scripts/Myscripts.js"></script>