By Brian, 1 year ago

Yahoo Releases YSlow

YSlow is an add-on for the popular FireBug add-on for the popular browser, FireFox. Confused? :D

It has neat tools to help you to improve your site's load times, and rates you accordingly. I scored an F on my blog. haha

Check it out: YSlow

By Brian, 1 year ago

BrainBench Certifications

I got an email tonight to take some free online tests. I took a couple, and scored pretty high in many areas, as I expected to, but also got stumped on a couple of the performance related issues (as I rarely deal with them). It's fun to see how you compare to others who have taken the same test.

You can view my complete transcript here:

Brain Bench Transcript

HTML Programmer Cert

DB Cert

apache config

By Brian, 1 year and 1 month ago

Getting a Global Array to work in a Function

I recently spent a lot of time debugging this code i was working on for what I thought would be a simple onchange event.

The Issue:
I have sizes and colors, but not all sizes are available in all colors, so onchange of the color select box, i need to load the correct size options select box.

Between a lot of back-end manipulation, I was able to create my front-end JS arrays of colors with the sizes that are available. I ran into the issue that my passed in variable to the function was becoming the array, instead of calling the array.

For example, If I passed in «BLK» for Black, I was getting:

  1. array[0] =>B
  2. array[1] =>L
  3. array[2] =>K
  4. array[N] => undefined

where the Nth options looped through undefined until my for loop for the options of my color box's length had been reached.

The Solution:
After scratching my head for hours and trying 232132 things, It turns out all I needed to do was to use the eval() function to evaluate my variable first, instead of treating it like a literal string.

Here's the completed working source:

  1.  
  2. function popsizes(colorcode) {
  3.  
  4.    var BLK= ["2XL","3XL","4XL","5XL","LG","MD","SM","XL","XS"];
  5.    var WH= ["LG","MD"];
  6.    // etc, many more color arrays
  7.  
  8.    elem = document.getElementById("selcolor");
  9.    sizelist = eval(colorcode);
  10.  
  11.    for (i=0; i<elem .options.length; i++) {
  12.   document.getElementById("selsize").options[i] = new Option(sizelist[i]);
  13.    }
  14. }
  15.  

That script is powered by the onchange event from the form:

  1. <tr>
  2.   <td>
  3.     <select "id="selcolor" name="color" onchange="popsizes(this.options[this.selectedIndex].value);">
  4.       <option value="WH">White</option>
  5.       <option value="BLK">Black</option>
  6.       <option value=""> Many more colors, etc .... </option>
  7.     </select>
  8.   </td>
  9.   <td>
  10.     <select "id="selsize" name="size">
  11.       <option value="">Select Color First</option>
  12.     </select>
  13.   </td>
  14. </tr>