Entry tags:
Question for anyone who knows Javascript...
This isn't about a broken script, as I've been able to get it to work. It's about a weird (to me) occurrence in an incrementing variable.
ETA: Solved! It's counting all the divs in the page. Headdesk time!
See, the variable x above? It iterates through three divs, so that I can switch between them and change the display status when someone chooses an option from a drop-down menu. (Er, no comments about whether the drop-down is a good idea or not: it was told to me to do. :D)
Anyway, x is showing up as 10, 11, and 12, instead of 0, 1, and 2 as I'd expect. I ended up having to name the divs Tab10, Tab11, and Tab12 to make it work. So while it's not a serious problem, it is a perplexing one.
Ideas? Explanations?
ETA: Solved! It's counting all the divs in the page. Headdesk time!
function showonlyone(thechosenone) {
var Tab = document.getElementsByTagName("div");
for(var x=0; x<Tab.length; x++) {
name = Tab[x].getAttribute("name");
if (name == 'Tab') {
if (Tab[x].id == thechosenone) {
Tab[x].style.display = 'block';
//alert('Boo - Tab' + x);
} else {
Tab[x].style.display = 'none';
//alert('Wah - Tab' + x);
}
}
}
}
See, the variable x above? It iterates through three divs, so that I can switch between them and change the display status when someone chooses an option from a drop-down menu. (Er, no comments about whether the drop-down is a good idea or not: it was told to me to do. :D)
Anyway, x is showing up as 10, 11, and 12, instead of 0, 1, and 2 as I'd expect. I ended up having to name the divs Tab10, Tab11, and Tab12 to make it work. So while it's not a serious problem, it is a perplexing one.
Ideas? Explanations?

no subject
All you'll need to do is in your code, replace < and > with < and > -- I usually do it in a text editor that has find a replace. Otherwise it can confuse the entry cleaner that's trying to figure out what HTML is where so that it can try and do things like, yes, clear out malware, or make sure someone's un-closed div doesn't wreck reading pages.
no subject
no subject
no subject
no subject
no subject