Hi All,
I am creating a html file where rows are being Genereated Dyanmically.
Now I want to pass the values of Input box to the perl File.
I am not able to send the values of row to the server side.
Can U please let me know Where I am facing the prob.
Thanks In advance.
perl File:
#!/usr/bin/perl
use strict;
use CGI;
my $q = new CGI;
print $q->header();
my $a = $q->param('txtRow');
print "This is A:- $a" ;
print "\n";
<html>
<head>
<title>Title of page</title>
</head>
<body>
<script type="text/javascript" >
function addRowToTable()
{
var tbl = document.getElementById('sample');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';el.name = 'txtRow' + iteration;el.id = 'txtRow' + iteration;
el.size = 40;
el.onkeypress = keyPressTest;
cellRight.appendChild(el);
}
function keyPressTest(e, obj)
{
var validateChkb = document.getElementById('chkValidateOnKeyPress');
if (validateChkb.checked) {
var displayObj = document.getElementById('spanOutput');
var key;
if(window.event) {
key = window.event.keyCode;
}
else if(e.which) {
key = e.which;
}
var objId;
if (obj != null) {
objId = obj.id;
} else {
objId = this.id;
}
displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
}
}
function validateRow(frm)
{
var chkb = document.getElementById('chkValidate');
if (chkb.checked) {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length - 1;
var i;
for (i=1; i<=lastRow; i++) {
var aRow = document.getElementById('txtRow' + i);
if (aRow.value.length <= 0) {
alert('Row ' + i + ' is empty');
return;
}
}
}
}
</script>
</body>
<form name=fp action="Test3.pl" method=get>
<p>
<input type="button" value="Add" onclick = "addRowToTable();"/>
<input type="submit" value="Submit" onclick = " validateRow(this.form)"/>
</p>
<table border="1" id ="sample">
<tr>
<th colspan="3">Sample Table </th>
</tr>
<tr>
<td> 1</td>
<td><input type="text" name="textRow1" id="textRow1" size ="40" onkeypress = "keypressTest(event,this);"/ ></td>
</tr>
</table>
</form>
</html>