hi, i need validate dinamic table javascript before i insert data do db, i m new here. please help me.
here is code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
</script>
<script type="text/javascript">
/*<![CDATA[*/
function addRow()
{
var tbl = document.getElementById('mySampleTable');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
var cellLeft = row.insertCell(0);
var doc = document.createElement('input');
doc.type = 'text';
doc.name = 'doc[]';
doc.id = 'doc' + iteration;
doc.style.width="100%";
cellLeft.appendChild(doc);
var id_age = "AGE"+iteration;
var func = row.insertCell(1);
var nome = document.createElement('input');
nome.type = 'text';
nome.name = 'nome[]';
nome.id = 'nome' + iteration;
nome.style.width="100%";
func.appendChild(nome);
}
function removeRow()
{
// grab the element again!
var tbl = document.getElementById('mySampleTable');
// grab the length!
var lastRow = tbl.rows.length;
// delete the last row if there is more than one row!
if (lastRow > 1) tbl.deleteRow(lastRow - 1);
}
/*]]>*/
</script>
<body>
<form id="form1" name="form1" method="post" onSubmit="return valida(this)" enctype="multipart/form-data" action="send.php">
<table width="50%" height="36" border="3" cellpadding="2" cellspacing="2" id="mySampleTable">
<tr>
<th width="9%" class="style5" scope="col"><div align="left">Doc Ident</div></th>
<th width="26%" scope="col"><div align="left" class="style5">Name</div></th>
</tr>
</table>
<p align="lefth">
<input type="button" value="Add" onClick="addRow();" />
<input type="button" value="Remove" onClick="removeRow();" />
<input name="send" type="submit" value="Send"/>
</p>
<p> </p></th>
<td></td>
</form>
</body>
</html>