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>

This is about the 5th post you've made on this topic. I understand how frustating it can be when no one answers your question. There might be valid reasons why you don't get an answer. I, for example, don't know PERL, and I also tend to skim past messages with giant code listings.

Also, from what I can tell from your posts, this is an on-going project that has had several issues. A forum is best for getting answers to very specific issues. People don't like to get wrapped up in others' nightmares, if you know what I mean!

So my advice is to try to isolate a specifiic problem, research that problem, and if there are still questions, post a short message, with your simplified code section that illustrates the problem. You might get better answers that way.

Personally, I don't know how good of an idea it is to use a submit button with an onclick event. I could be wrong, and still living in earlier days, but I would use a button, with an onclick, and then do a form.submit(); to submit the form. The perl code looks fine (taken from a book, pretty much, but fine). A Debugging suggestion here, is to use alerts throughout your code, and walk through the page, line by line if necessary, with alerts in each code block. Alert the values of your variables or elements, and make sure that you are passing something other than blank or null information to the perl script.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.