Well, I've got some code here that I can see what's happening but don't know how to fix it or if it is a limitation with Firefox vs. IE. I have a drop down on an asp page that has an editable slot. You can type in the value that you want and it stores it into the last slot of of drop-down. However, IE will recognize and store the spaces but FF will not. FF converts the char code into a string and stores it into a variable that stores the word or phrase. The word or phrase gets stored into the index of the drop-down, which removes the space during storage. IE stores the word into the index without any problems. This is the javascript:
Is this a limitation and what can I do to fix it? I really need to find a solution for this. Any tips?
Todd
Code:
// space bar works in IE, not in FF (char code 32)
if(c >= 32 && c <= 126) // Printable characters
{
if ((c == 32) && (navigator.appName=="Netscape")) // if space bar pressed, add an empty space
combo_word += " "; // combo_word stores empty space*/
alert("String.fromCharCode(c):" + String.fromCharCode(c) + ";");
combo_word += String.fromCharCode(c); // removes spaces
//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;
}
else if((c == 8 || c == 4099) && combo_word.length>0) // Backspace
{
combo_word = combo_word.substring(0, combo_word.length-1);
//element.options[2].value = combo_word; // take_id will not be selected
// and default to 0
element.options[2].text = combo_word;
element.selectedIndex = 2;
}
Todd