Archive for Javascript/AJAX

Dynamic Select Boxes

I need to have two select boxes. One with a major category, and once selected another one appears with sub categories.

For sake of example, say I have 8 major categories.

At first, I thought I’d just make 8 selects with the sub categories, and just hide/show the ones I didn’t need or need. Fine .. but the form still sees them when you submit! so my subcategory name was getting overwritten by the hidden selects. No good.

I load my data into a javascript array, so I do the dyamic thing where I loop through the array and add options to the DOM. Fine .. works.

something like:

for (s in data) {
label = "       "+data[s][1];
$(’sub_cat_select’).options[i] = new Option(label, data[s][0]);
i++;
}

But — my subcategoris are actually “tree like” and there are sub categories. With my hidden selects, in php I added & nbsp ; to create an “indent” which showed up fine. However, usin the dom, my & nbsp didn’t work.. and neither did putting a real space.

I just find it weird that if I used php to print my option lists with the & nbsp … it worked.. but then putting the & nbsp when doing the dom way it didn’t work. Any suggestions on how to indent? next I am trying style sheets, but I think that will be a bit of a pain.

Comments (2)

View Rendered Source — for IE

IE was being a bad boy and I wasn’t sure it was rendering my ajax correctly. I was wishing for a View Rendered Source like I have for FF. I searched, found but it didn’t install right..and found 2 commercial ones. Ugh. I don’t know if work would go for that.

The I thought.. hmm I could make a link “view source” (for when I need to debug) and have it grab the text of html, format… and make it display? hmm.. I was working on that then left for lunch.

Then I get to Panera bread for lunch and realize.. hmm wonder if I can make this a bookmarklet so I don’t need to put tag in my page… then I thought.. hmm maybe there already exists one… so I search.. and found one! and it works… its not color coded like FF but it works:

http://javascript.about.com/library/blsource.htm

Yeah.

Comments

Javascript Debugger extension out.. for FF 1.5

Found out last night from the DotProject IRC room that the newest Venkman, the Javascript debugger is out. I had to uninstall the old version manually then install this new one. Sweet. I was missing this…

In case you don’t haven’t used it, its an excellent tool for stepping through your Javascript and watching variables. Even tests ajax type things too! Another of my favorite extentions is FireBug which I use when I just want to see what XML requests are being called (ie. is this DERNED THING WORKING?!?!).

If you are really hard up for entertainment … check out this person who installed 100 firefox extentions..

Am I missing out on any cool FF developer extentions??

Comments