I have a block of javascript code that takes printable characters, converts them to a string and adds them together to create a word. I have come across a problem in FF that when the space bar is pressed, the code does not add a space to the combo_word value. IE has no problem handling this the correct way. Is this a limitation of Firefox?
I have added code to try and handle char code 32, you shoudl see it in the above code, but it will not add a space to the string. Any ideas how to solve this?
Thanks,
Todd
Code:
// space bar works in IE, not in FF (char code 32)
if(c>=32 && c<=126) // Printable characters
{
if (c == 32) // if space bar pressed, add an empty space
if (navigator.appName=="Netscape") // FF
combo_word += " ";
combo_word += String.fromCharCode(c);
//element.options[2].value = combo_word; // take_id will not be selected
// and default to 0
element.options[2].text = combo_word;
var combo_wlc = combo_word.toLowerCase();
var combo_select = 2;
for(i=1; i<element.options.length; i++)
{
combo_sel = element.options[i].text.toLowerCase();
if(combo_wlc.length <= combo_sel.length)
{
combo_sel = combo_sel.substring(0, combo_wlc.length);
if(combo_wlc == combo_sel)
combo_select = i;
}
}
element.selectedIndex = combo_select;
}
I have added code to try and handle char code 32, you shoudl see it in the above code, but it will not add a space to the string. Any ideas how to solve this?
Thanks,
Todd