| | |
Need Help Urgently
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2006
Posts: 8
Reputation:
Solved Threads: 0
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>
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>
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
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.
Last edited by tgreer; Apr 17th, 2006 at 6:33 pm.
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.
![]() |
Similar Threads
- I need .NET basic interview questions urgently (C#)
- C++ Assignment NEED HELP URGENTLY (C++)
- My D: drive won't open! (Storage)
- Help Needed Urgently With Coding (Java)
- Active Directory (Windows NT / 2000 / XP)
- Preparing for an interview and need some questions answered (C)
- Syntax for deleting specified file ( in C++) (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Location of Javascript files on server
- Next Thread: Calendar window is not coming for the Dynamic rows
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captchaformproblem cart checkbox child class close codes css date debugger decimal dependent design disablefirebug dom editor element embed engine enter events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post programming prototype rated redirect runtime safari scale scriptlets scroll search security session shopping size software star starrating stars synchronous toggle unicode variables web webservice wysiwyg \n






