question on HTML DOM Select Object

Discussion in 'JavaScript' started by lunlun, Dec 14, 2007.

  1. #1
    To clarify, the thing i'm trying to insert is,
    http://www.w3schools.com/htmldom/dom_obj_select.asp


    I have a table and i want to insert a select object into one of the cell. but i am getting a "Type mismatch" error on line with code "cell.insertBefore(selectBox);"


    I am running IE 6



    		var cRow = document.getElementById("displayCondition").insertRow(rowIndexDC++);
    			
    			if (rowIndexDC % 2 == 0)
    				cRow.bgColor = "#cccccc";
    			
    			var cell0 = cRow.insertCell(0);
    			var cell1 = cRow.insertCell(1);
    			var cell2 = cRow.insertCell(2);
    			var cell3 = cRow.insertCell(3);
    			var cell4 = cRow.insertCell(4);
    			var cell5 = cRow.insertCell(5);
    			cell5.align = "center";
    			
    			if(rowIndexDC != 3) {
    				var selectBox = document.createElement('select');
    				
    				var option = document.createElement('option');
    				option.text = "And";
    				
    				try
    			    {
    				    selectBox.add(option, null); // standards compliant
    			    }
    				  catch(ex)
    			    {
    				    selectBox.add(option); // IE only
    			    }
    						
    			
    			} 	cell1.insertBefore(selectBox, cell1.childNodes[0]);
    
    
    Code (markup):
     
    lunlun, Dec 14, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Now why would you torture yourself like that?
     
    MMJ, Dec 15, 2007 IP