I have JavaScript creating a generic select box when you double click in a table cell and when an option is clicked, the select box is removed and the option selected is recorded. The table cell displays the option selected.
However, if the table cell is double clicked and the select box is created, but then you just click out of the select box without selecting an option, the select box remains and the rest of the page from then on breaks.
I want the select box to be removed if the focus is lost, but the onblur method that works with input boxes doesn't seem to work with select boxes.
Does anyone know what event is triggered?
JavaScript code when table cell is double clicked to make a select box:
var object_input = document.createElement ("SELECT"); //Put an select box in the cell
object_input.setAttribute("name", "course_price_select");
object_input.setAttribute("id", "course_price_select");
object_input.style.width = (current_cell.clientWidth - 20) + "px";
object_input.attachEvent ("onblur", focus_lost);
object_input.attachEvent ("onkeypress", checkForEnter);
These two lines don't work! (focus_lost and checkForEnter methods start with alert('hi'); so I know they are not being triggered)
object_input.onchange = function() {focus_lost()};
//Populate with options....
attachEventis specific to IE. Try usingaddEventListenertoo.Uncaught TypeError: Object #<HTMLInputElement> has no method 'attachEvent'.attachEventis IE-only!