hello, could anyone help me?
i am a beginer in java script and i want to put data from the form into a existing table and for every set of value fill in the text boxes of the form when these data are inserted in a table (but it doesn't work)a new row is inserted and in this rows are exported the data from form.
thank you in advance
i am a beginer in java script and i want to put data from the form into a existing table and for every set of value fill in the text boxes of the form when these data are inserted in a table (but it doesn't work)a new row is inserted and in this rows are exported the data from form.
thank you in advance
Code:
<html>
<head>
<script type="text/javascript">
function formValidation()
{
var nrfacturaid = document.form1.nrfactura;
var udatafactura = document.form1.datafactura;
var tipfacturaid = document.form1.tipfactura;
var valoarefacturaid = document.form1.valoarefactura;
var uobservatii = document.form1.observatii;
function nrfactura_validation(nrfacturaid)
{
var p=document.all["form1"]["nrfactura"].value.length;
if (p==null || p=="")
{
alert("completeaza primul nume");
return false;
}
else if(p>20)
{
alert("nr maxim de caractere permise este 20");
return false;
}
else("poti trece mai departe");
{
return true;
}
}
//
function insRow(nrfacturaid,udatafactura,tipfacturaid,valoarefacturaid,uobservatii)
{
insRow(nrfactura.value,datafactura.value,tipfactura.value,valoarefactura.value,observatii.value)
var x=document.getElementById('myTable').insertRow(1);
var y=x.insertCell(0);
var z=x.insertCell(1);
var k=x.insertCell(2);
var l=x.insertCell(3);
var m=x.insertCell(4);
y.innerHTML="nrfactura";
z.innerHTML="datafactura";
k.innerHTML="tipfactura";
l.innerHTML="valoarefactura"
m.innerHTML="observatii"
document.write("myTable").insRow(nrfactura.value);
}
}
//
</script>
</head>
<body>
<form name="form1" onsubmit="return formValidation()" >
<tr>
<td>nr factura </td>
<td><input type="string" name="nr factura" size="12" /></td>
</tr>
</br>
<tr>
<td>data factura</td>
<td><input type="text" name="data factura" size="40" /></td>
</tr>
</br>
<tr>
<td>tip factura</td>
<td><select id="tip factura" name="tip factura">
<option value="tip1"> tip1</option>
<option value="tip2">tip2</option>
<option value="tip3">tip3</option>
</select></td>
</tr>
</br>
<tr>
<td>valoare factura</td>
<td><input type="number" name="valoare factura" size="40"/></td>
</tr>
</br>
<tr>
<td>observatii<br>
(optional)
<td><textarea name="observatii" rows="10" cols="20"></textarea></td>
</tr>
</br>
</br>
<table id="myTable" border="2" onsubmit="return insRow(value)">
<tr>
<td>Nr factura</td>
<td>Data</td>
<td>tip factura</td>
<td>valoare</td>
<td>observatii</td>
</tr>
</table>
<br />
<input type="submit" value ="submit" onsubmit="insRow ()">
</br>
<tr>
<td><input type="reset" name="reset" value="reset"/></td>
<td> </td>
</tr>
</table>
</form>
</body>
Comment