home   about us   products/services   news   clients   partners   contact



Run Your Own Online Store!
Click here to find out about our hot deals for fully managed ecommerce hosting plans!

Dollar for dollar, feature for feature, we offer the best ROI value on the web!
Click here to read testimonials from happy customers!

Check out our online demos by clicking  the thumbnails below:

   
Demo Store
   
Shopping Cart Demo

    Demo Admin
    Shopping Cart Demo

  Liked it?  
  Sign-up Now!
  
  Need more info?
 
Contact us...

Tech Forum

Solutions from our software gurus:

Contents:
ASP: Generating ASP code using ASP
JavaScript: Validating credit card numbers
JavaScript: Accurate rounding of decimals
JavaScript: Detecting an empty field

The solutions below are free to copy and use, no strings attached.
You can rename them if you want but you might want to keep the Copyright Notice so credit will be given where credit is due. If you don't, no big deal, it's your karma after all...

An ASP Trick:

Highly flexible,  Active Server Pages and its VB-like language are a neat way to provide dynamic content to web sites. Since ASP code is processed at the server level, it also allows generation of code (HTML, XML or JavaScript, etc...) that will be executed by the browser or even generation of HTML files using the File Scripting Object. Talk about flexible! 
Here is a trick that allows your ASP page to generate ASP code (for instance if you generate template pages from an ASP application). This requires a trick to prevent your ASP page to interpret the generated ASP literally.

Example: 
We want to output a call to an ASP sub-routine call while using ASP to write an ASP file:

The statement below generates a syntax error because ASP interprets the tags literally:
fs.WriteLine "<%myRoutine(prm1, prm2, ...)%>"  <--- Syntax error!

How-to:
The ASP interpreter needs to be fooled by supplying the needed tags in a way it does not recognize and therefore will ignore:
fs.WriteLine "<" & Chr(37) & "rc=myRoutine(prm1, prm2, ...)" & Chr(37) & ">"
When we substitute the % character with its equivalent Chr(37), the ASP interpreter leaves us alone and allows the ASP function to generate the ASP code in the page.

The same trick works when generating file inclusion statements:
inclBegin = "<!-- #"
inclEnd = " -->"
fs.WriteLine inclBegin & "include virtual=/myinclude.inc" & inclEnd

Kinda weird, but can save you a whole lot of headaches...

JavaScript validation of credit card numbers:
 
This routine cannot tell you whether customers are over their spending limit but at least it allows you to detect phony numbers before the bank does.

//
/
/ Check LUHN  - © 2001 - //digital things - www.digithings.com
//
function DTCValidateLUHN(ccNum) 
{
    var ccLen = ccNum.length;
    var oddoeven = ccLen & 1;
    var sum = 0;

    for (var n = 0; n < ccLen; n++)
    {
        var digit = parseInt(ccNum.charAt(n));

        if (!((n & 1) ^ oddoeven))
        {
            digit *= 2;
            digit = digit > 9 ? digit-9 : digit;
        }

        sum += digit;
    }

    return sum % 10 ? false : true;
}


The never rounding Java:
 
If you have ever worked with JavaScript, you have probably noticed that the Math.round() function only rounds numbers into integers, equivalent to a call to VB/ASP Round(n, 0). 
We needed a reliable way of rounding floats and we created the DTCRound() function to this effect. 
The function uses powers of 10 to provide a functionality similar to the VB/ASP Round() function.

//
// DTCRound() - © 2001 - //digital things - www.digithings.com
// Accurately rounds decimals.
//
function DTCRound(value, decimals)
{
    return(
              parseFloat(value) != "NaN" && parseInt(decimals) != "NaN" 
              ? (Math.round(value * Math.pow(10, decimals))) / Math.pow(10, decimals) 
              : "NaN"
              );
}


Is this field really empty?
When you do client-side validation, you sometimes want to make sure that the user is not trying to fool you by entering a 'space' to make the application 'believe' a required field is not empty.
The function below handles this case. You just pass it a 'form.fieldname' as parameter and it does the rest, returning 'true' if the field is empty, 'false' otherwise.

//
// DTCFieldIsEmpty() - © 2001 - //digital things - www.digithings.com
// Returns true if the passed field is empty (null or spaces), false otherwise.
//
function DTCFieldIsEmpty(field)
{
    var i = 0;
    var n = 0;

    //  Field is null.
    if (field.value.length == 0)
        return true;

    //  Scan string to make sure it is not just white space (number of spaces = length).
    for (i = 0; i < field.value.length; i++)
    {
        if (field.value.charAt(i) == " ")
            n++;
    }

    if (n && i == n)
        return true;

    return false;
}


We hope to see you soon back here for more goodies. We try to publish new solutions & trick whenever possible, but we have deadlines to meet...

Fight Back IM Monopolists!

Download universal IM clients for all IM protocols (AOL, MSN, Yahoo!, etc...). We are not associated with Jabber or Trillian but we support their philosophy and oppose monopolistic attempts by some of those large ISPs  to control and regiment  IM access. 
The Internet IS about inter-communication!

Click on the logo to go to the download page:

      

      

 

 

 

 

 

 

home   about us   products/services   news   clients   partners   contact

  copyright © 2008 digital things llc - all rights reserved.