Misspell
09-22-2005, 06:27 AM
Hello all... looking for alittle help, here.
Can somone explane to me how this code works.
:snip:
var parts = {front:1<<0, back:1<<1, cd:1<<2, cd2:1<<3, cd3:1<<4, cd4:1<<5, inside:1<<6, inlay:1<<7};
var titleCode = elem.options[elem.selectedIndex].value;
for (var i in parts) {
if(titleCode&parts[i]) {
//alert(titleCode + " <>" + i);
buffer += '[<a href="" onClick="titlePart.value=\''+i+'\';titleSubmit.focus();return false;" ';
buffer += 'onMouseOver="window.status=\''+ucFirst(i)+'\';return true;" onMouseOut="window.status=\'\';return true;">';
buffer += '<strong>'+ucFirst(i)+'</strong></a>] ';
}
}
:/snip:
I know what the out come is and where the info is coming from, but dont know how it does its thing.
Heres an example of what it does:
elem.options[elem.selectedIndex].value is 197 (taking from a <select> box off a form)
when looping through the 'parts' array (is that what it is ? thought arrays where defined differently in javascript) it will turn that 197 into;
[Front] [Cd] [Inside] [Inlay] (takin from the 'parts' "array")
The ucFirst() function just capitalize the first letter of the values held in the 'parts' array.
Another example...
If elem.options[elem.selectedIndex].value = 1 then it would return;
[Front]
If elem.options[elem.selectedIndex].value = 5 it would return;
[Front] [Cd]
Theres all different values for elem.options[elem.selectedIndex].value which display different combinations of the 'parts' array.
So... whats going on with all that ???
And what does the #<<# in the 'parts' array mean/do ?
As you can see, I dont know too much about Javascript (im more of a simple PHP and VB programmer).
The attach file is the javascript and a clip of the form that calls the script (so you can see it in action).
Heres what im doing (if you care :) ).
I have a VB program ive made for myself and a friend.
With-in this program i 'Inet' a url and then i phase through the HTML source and pull out the info we want, then display that info in a listview. Noramly part of that info would work with the javascript, but im converting that to function under VB. Im not looking for the "javascript => VB" code here, i would just like to know excatly how the code above translates the numbers into the words and what the #<<# does.
Hope that made sense, thanks for any help.
Can somone explane to me how this code works.
:snip:
var parts = {front:1<<0, back:1<<1, cd:1<<2, cd2:1<<3, cd3:1<<4, cd4:1<<5, inside:1<<6, inlay:1<<7};
var titleCode = elem.options[elem.selectedIndex].value;
for (var i in parts) {
if(titleCode&parts[i]) {
//alert(titleCode + " <>" + i);
buffer += '[<a href="" onClick="titlePart.value=\''+i+'\';titleSubmit.focus();return false;" ';
buffer += 'onMouseOver="window.status=\''+ucFirst(i)+'\';return true;" onMouseOut="window.status=\'\';return true;">';
buffer += '<strong>'+ucFirst(i)+'</strong></a>] ';
}
}
:/snip:
I know what the out come is and where the info is coming from, but dont know how it does its thing.
Heres an example of what it does:
elem.options[elem.selectedIndex].value is 197 (taking from a <select> box off a form)
when looping through the 'parts' array (is that what it is ? thought arrays where defined differently in javascript) it will turn that 197 into;
[Front] [Cd] [Inside] [Inlay] (takin from the 'parts' "array")
The ucFirst() function just capitalize the first letter of the values held in the 'parts' array.
Another example...
If elem.options[elem.selectedIndex].value = 1 then it would return;
[Front]
If elem.options[elem.selectedIndex].value = 5 it would return;
[Front] [Cd]
Theres all different values for elem.options[elem.selectedIndex].value which display different combinations of the 'parts' array.
So... whats going on with all that ???
And what does the #<<# in the 'parts' array mean/do ?
As you can see, I dont know too much about Javascript (im more of a simple PHP and VB programmer).
The attach file is the javascript and a clip of the form that calls the script (so you can see it in action).
Heres what im doing (if you care :) ).
I have a VB program ive made for myself and a friend.
With-in this program i 'Inet' a url and then i phase through the HTML source and pull out the info we want, then display that info in a listview. Noramly part of that info would work with the javascript, but im converting that to function under VB. Im not looking for the "javascript => VB" code here, i would just like to know excatly how the code above translates the numbers into the words and what the #<<# does.
Hope that made sense, thanks for any help.