Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • JavaScript Resources
    02/20/2012 3:07PM
  • ECMAScript 5 Compatibility Table
    02/20/2012 2:16PM

    Very handy ECMAScript 5 compatibility table for the JavaScript programmer:

    http://kangax.github.com/es5-compat-table/

  • Javascript Debugging Under IE7 with Companion.JS
    06/02/2011 2:16PM
    1. Make sure that you have the Microsoft Script Debugger Engine installed: Script Debugger
    2. Install CompanionJS toolbar.
    Enable the tool bar via View/Explorer Bar/Companion.JS
  • Accessing JSON Data Under IE7
    06/02/2011 1:57PM

    Given the following JSON object:

    var var_affectedAreas = {
    ??? ??? 'areaCount' : 6,
    ??? ??? 'areasList': [
    ??? ??? ????????????? {'enum': 'FILE', 'val': 'F'},
    ??? ??? ????????????? {'enum': 'REGISTRY', 'val': 'R'},
    ??? ??? ????????????? {'enum': 'PROCESS', 'val': 'P'},
    ??? ??? ????????????? {'enum': 'MEMORY', 'val': 'M'},
    ??? ??? ????????????? {'enum': 'NETWORK', 'val': 'N'},
    ??? ??? ????????????? {'enum': 'OTHER', 'val': 'O'}
    ??? ??? ]
    };

    You would think (and rightly so, at least under Firefox) that you would be able to access data in this object via the following:

    areaCell = var_affectedAreas.areasList[var_areasCount].enum;
    areaCell = eval("var_affectedAreas.areasList[" + var_areasCount + "].enum");
    areaCell = eval("var_affectedAreas.areasList['" + var_areasCount + "'].enum");

    However, IE7 does not like that syntax and throws syntax errors.

    The following syntax works under both IE7 and Firefox.

    areaCell = var_affectedAreas["areasList"][var_areasCount]["enum"];


  • Applying Order to JSON Data When Rendering to a Page
    05/20/2011 9:31AM

    It is very convenient to pass JSON data from client to server and between different server-side components.? However, JSON data is an inherently unordered data structure and in many cases a developer will want to render a list of items in some specified order.

    One way that I found to do so is to append an integer to the keys in your data when generating the JSON data.? For example, you might be iterating through a database result set and want to maintain the order in which the result was returned.? When adding your keys append '_n' to the string.

    Then, when you access the JSON data (with JavaScript, and jquery, and assuming a reference to your JSON data is 'data') first get a count of the number of objects in your JSON container:

    $counter = 0;

    $.each(data, function(key, value) {

    ? ?? $counter++;

    ???? alert(key + ': ' + eval(value.id));

    });

    Now we have a count of the number of items in the object and run a for loop using the $counter variable.

    for(var $rowCounter = 0; $rowCounter < $counter; rowCounter++) {

    ? ?? // Access your data using the $rowCounter value

    ? ?? alert("row " + $rowCounter + " = " + eval("data.row_" + $rowCounter));

    }

Advanced Search

Categories

Archives