anybody could give a workaround for this?
hi all,
following code will generate runtime exception, though the code was copied from msdn!
<html> <head> <SCRIPT>
<!-- counter = 0; var text="1"; var value="1";
function addRow(id){ var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0]; var row = document.createElement("TR"); var td1 = document.createElement("TD") ;
/* create the input element as a seperate reference */ var input = document.createElement("INPUT");
/* append the attributes to the input element, not td */ input.setAttribute("type","text"); input.setAttribute("name","tbox"+counter); input.setAttribute("id","tbox"+counter); td1.appendChild(input);
counter++
var td2 = document.createElement("TD") ; var input2 = document.createElement("INPUT") ; input2.setAttribute("type","text"); input2.setAttribute("name","tbox"+counter); input2.setAttribute("id","tbox"+counter);
counter++
var td3 = document.createElement("TD") ; var input3 = document.createElement("select") ;
var option1 = document.createElement("option"); input3.options.add(option1);//WILL THROW EXCEPTION HERE!!!!!! option1.value = "abc"; option1.text="abc";
input3.setAttribute("id","tbox"+counter); input3.appendChild(option1); input3.appendChild(option2);
counter++
td2.appendChild(input2); td3.appendChild(input3); row.appendChild(td1); row.appendChild(td2); row.appendChild(td3); tbody.appendChild(row);
input.focus(); input3.onchange=addRow2; }
function addRow2(){ addRow('myTable'); }
function add_one_option (text, value, my_listbox) { var oOption = document.createElement("OPTION"); oOption.text=text; oOption.value=value; my_listbox.options.add(oOption) return true; }
// End -->
</SCRIPT> </head> <BODY onLoad="document.getElementById('first').focus();">
<form name=test action=abc.jsp> <TABLE border=1 cellSpacing=0 id=myTable> <TBODY> <TR> <TD> column1</TD> <TD> column2</TD><TD> column3</TD> </TR>
<!-- FOLLOWING onfocus="true" NOT WORKING --> <TR> <TD><input type=text id="first" name=a onfocus="true"></TD> <TD><input type=text name=b ></TD><TD><select size=1 name=c onchange="addRow('myTable')"> <option value=a> <option value=a>A <option value=a>B <option value=a>C</TD> </TR> </TBODY> </TABLE>
<input TYPE = "submit" VALUE = "submit"> </form> </BODY>
any guru can solve this? thank you very much in advance!!! Started By jiangzhan on Jun 1, 2002 at 11:55:21 AM |