|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Error saying null or not an object.
Im getting an error saying document.forms.classic.option is a null or not an object... actually my code every time a user enters an add row button it will add a row and then on selecting a combobox in a row another combo box will populate and then selecting that another combobox will populate ,all of dem in d same row , but when i add the second row and choose any thing in the first combo box i get dis error... kindly help...
<body> <form name="classic"> <TABLE ID="tblPets" border="1" STYLE="border width:1 orange dashed;background color:#F0E68C;table-row width:2;"> <TR> <TH>S.No</TH> <TH WIDTH="70">ABC</TH> <TH WIDTH="230">type</TH> <TH WIDTH="70">var</TH> <TH WIDTH="70">calc</TH> <TD ALIGN="center"><INPUT TYPE="Button" onClick="addRow('tblPets')" VALUE="Add Row"></TD> </TR> <TR> <TD>1</TD> <TD>xyz</TD> <TD>2-3-2</TD> <TD>2</TD> <TD>2</TD> <TD><INPUT TYPE="Button" CLASS="Button" onClick="delRow()" VALUE="Delete Row"></TD> </TR> <TR> <TD>2</TD> <TD>xyw</TD> <TD>3-2-3</TD> <TD>4</TD> <TD>3</TD> <TD><INPUT TYPE="Button" CLASS="Button" onClick="delRow()" VALUE="Delete Row"></TD> </TR> </TABLE> <SCRIPT TYPE="text/javascript"> var gUniqueRowID = 0; var count = "1"; function addRow(in_tbl_name) { gUniqueRowID += 1; var tbody = document.getElementById(in_tbl_name).getElementsBy TagName("TBODY")[0]; // create row var row = document.createElement("TR"); // create table cell 1 var td1 = document.createElement("TD") var strHtml1 = "<FONT SIZE=\"3\">#ROWID#</FONT>"; td1.innerHTML = strHtml1.replace(/#ROWID#/g,""+gUniqueRowID); // create table cell 2 var td2 = document.createElement("TD") var strHtml2 = "<INPUT TYPE=\"text\" NAME=\"in_name\" SIZE=\"30\" MAXLENGTH=\"30\" STYLE=\"height:24;border: 1 solid;margin:0;\">"; td2.innerHTML = strHtml2.replace(/!count!/g,count); // create table cell 3 var td3 = document.createElement("TD") var strHtml3 = "<SELECT NAME=\"Animal\"onChange=\"updateSize()\"><OPTION VALUE=\"2\">2-3-3<OPTION VALUE=\"3\">3-2-4<OPTION VALUE=\"4\">4-3-4</SELECT>"; td3.innerHTML = strHtml3.replace(/!count!/g,count); // create table cell 4 var td4 = document.createElement("TD") var strHtml4 = "<select name=\"size\"onChange=\"updateSize1()\"></select>"; td4.innerHTML = strHtml4.replace(/!count!/g,count); // create table cell 5 var td5 = document.createElement("TD") var strHtml5 = "<select name=\"size1\"></select>"; td5.innerHTML = strHtml5.replace(/!count!/g,count); // create table cell 6 var td6 = document.createElement("TD") var strHtml6 = "<INPUT TYPE=\"Button\" CLASS=\"Button\" onClick=\"delRow()\" VALUE=\"Delete Row\">"; td6.innerHTML = strHtml6.replace(/!count!/g,count); var td7 = document.createElement("TD") var strHtml7 = "<INPUT TYPE=\"Button\" CLASS=\"Button\" onClick=\"reload()\" VALUE=\"Ok\">"; td7.innerHTML = strHtml7.replace(/!count!/g,count); // append data to row row.appendChild(td1); row.appendChild(td2); row.appendChild(td3); row.appendChild(td4); row.appendChild(td5); row.appendChild(td6); row.appendChild(td7); // add to count variable count = parseInt(count) + 1; // append row to table tbody.appendChild(row); } function reload() { window.location.reload() } function delRow() { var current = window.event.srcElement; //here we will delete the line while ( (current = current.parentElement) && current.tagName !="TR"); current.parentElement.removeChild(current); } function updateSize() { currSelect = document.forms["classic"].Animal.options[document.forms["classic"].Animal.selectedIndex].value //create options based on selection if (currSelect == "3"){ //paramaters are (display text,value,default selected,selected) document.classic.size.options[0]=Option("2Pass","2Pass") document.classic.size.options[1]=Option("3Pass","3Pass") document.classic.size.options[2]=Option("4Pass","4Pass",true,true) }else if (currSelect == "4"){ document.classic.size.options[0]=Option("3Pass","3Pass") document.classic.size.options[1]=Option("4Pass","4Pass") document.classic.size.options[2]=Option("5Pass","5Pass",true,true) } } function updateSize1() { currSelect = document.classic.size.options[document.classic.size.selectedIndex].value //create options based on selection if (currSelect == "2Pass"){ //paramaters are (display text,value,default selected,selected) document.classic.size1.options[0]=Option("2Post","2Post") document.classic.size1.options[1]=Option("3Post","3Post") document.classic.size1.options[2]=Option("4Post","4Post",true,true) }else if (currSelect == "3Pass"){ document.classic.size1.options[0]=Option("3Post","3Post") document.classic.size1.options[1]=Option("4Post","4Post") document.classic.size1.options[2]=Option("5Post","5Post",true,true) } } </SCRIPT> </body> </form> |
|
#2
|
|||
|
|||
|
hey jang i tried ur code but can u tell me from where u r using that option becauswe the is nothing.
i will send u one of my code and you can check it out. i will send it later in the day |
|
#3
|
||||
|
||||
|
hello,
i am thinking of a way that we could do this, if you want me to work on this subject. the way i understand what you want is that you want to beable to click to add a text-field and also click another button to delete it, if this is true we could use a <div> layer and a fuction consisting of a "for" loop controled by a counter, anyway, if you want me to work on it, email me at Colton22@comcast.net and i will, you have gotten me intrested in doing this so i probably will do this anyway colton -- http://www.freewebs.com/colton22 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Error saying null or not an object. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|