PDA

View Full Version : accessing dynamic text box



sri_madhu
10-09-2005, 02:06 AM
hai guys , iam trying to create dynamic text boxes and access them.So, far creating is ok.But i could not access those dynamic text boxes .i don't know why? could any body plz tell me what is the problem.

i have two text boxes on the form which are not dynamically generated.when i click on "insert row" button a new row is added and i want to access those text boxes generated dynamically. but i coluld not access these dynamic text boxes.

Here is the code


<HTML>
<HEAD>

<TITLE>dynamic</TITLE>


<script language="javascript">

<!--
var rownum=1

function addRow()
{
rownum++;
var tbody = document.getElementById("table1").getElementsByTagName("tbody")[1];
var row = document.createElement("TR");

var cell0 = document.createElement("TD");
var inp0 = document.createElement("INPUT");
inp0.setAttribute("type","text");
inp0.setAttribute("name","Sno" + rownum);
inp0.setAttribute("size","2");
inp0.setAttribute("value", rownum);
inp0.setAttribute("disabled", true);
cell0.appendChild(inp0);


var cell1 = document.createElement("TD");
var inp1 = document.createElement("INPUT");
inp1.setAttribute("type","text");
inp1.setAttribute("name","Width" + rownum);
inp1.setAttribute("size","10");
inp1.setAttribute("value","Width" + rownum);
cell1.appendChild(inp1);


var cell2 = document.createElement("TD");
var inp2 = document.createElement("INPUT");
inp2.setAttribute("type","text");
inp2.setAttribute("name","Drop" + rownum);
inp2.setAttribute("size","10");
inp2.setAttribute("value","Drop" + rownum);
cell2.appendChild(inp2);


row.appendChild(cell0);
row.appendChild(cell1);
row.appendChild(cell2);

tbody.appendChild(row);
}

function validate(the)
{
i=document.FORM1.Drop1.value;
alert(i);
i= document.FORM1.Drop2.value;

alert(i)

submit();


}


-->




</SCRIPT>


</HEAD>
<BODY>


<P>
<FORM id=FORM1 name=FORM1 action="tieupfinal1.asp" method=get></P>
<p align=center> <b>
<U>WALL SECTIONS,HAND ROLL WITH TIE STRAPS<b></U>
</P>
<br>
<br>










<p> Material : <select size="1" name="Material">

<option selected>SelectOne </option>
<option>Clear Plastic SHD 4600</option>
<option>Tinted Plastic SHD 4800</option>
<option>PVC Mesh SHD 5000</option>

</select>

</p>




<table id="table1" cellSpacing=1 cellPadding=1 border=1>
<TR >
<TD rowSpan=2 size=4>&nbsp;No</TD>
<TD colSpan=2>
<CENTER >Measurments as per<BR>"Required
Measurements"<BR>sheets</CENTER></TD>
</TR>
<TR>
<TD>
<CENTER>Width </CENTER></TD>
<TD>
<CENTER>Drop </CENTER></TD>
</TR>
<tbody>
<TR name=row1 >
<TD ><input type="text" name="Sno" size=2 value=1 disabled></TD>
<TD><input type="text" name="Width1" size=10></TD>
<TD><input type="text" name="Drop1" size=10></TD>

</TR>
</tbody>
</table>

<input type="button" value="Insert Row" onClick="addRow();">
<input type="Submit" Value="do it" onClick="validate(this);">

</Form>




</BODY>
</HTML>