How to get input text boxes populated / perl cgi?


 
Thread Tools Search this Thread
Top Forums Web Development How to get input text boxes populated / perl cgi?
# 1  
Old 07-06-2014
How to get input text boxes populated / perl cgi?

Hi,

I know how to populate a combo box or a drop down list box which I do as under :

Query that gets the data for the drop down box :

Code:
 
$qry = "select \"EmployeeID\" AS empid, \"FirstName\"::text || ' ' ||\"LastName\"::text as name from \"Employees\"";
$qq = $db_handle->prepare($qry);
$qq->execute;
while (@row = $qq->fetchrow) {
         $tt .= "<option value=$row[0]>$row[1]</option>\n";
                 }

And below is how I assign the values driven from database to a drop down lis box which gets populated :

Code:
<form method=POST>
Select an employee to be updated and press FETCH:<select name=empid>$tt</select><br>
..............

Now back to the input text boxes how do I populate them, how do I assign values to them :
Here is the query that fetches data for the input text boxes but I don't know how to assign values driven from the query to the text boxes :

Code:
# If the form has been completed, save data entered
if ($input{"go"} eq "FETCH") {
$query = "SELECT 
              \"LastName\" AS ln, 
              \"FirstName\" AS fn,
              \"Title\" AS tl,
              \"TitleOfCourtesy\" AS tc,
              \"BirthDate\" AS bd,
              \"HireDate\" AS hd,
              \"Address\" As ad, 
              \"City\" AS ct,
              \"Region\" AS rg, 
              \"PostalCode\" AS pc, 
              \"Country\" AS cy,
              \"HomePhone\" AS hp, 
              \"Extension\" AS xt, 
              \"Notes\" AS nt, 
              \"ReportsTo\" AS rt
          FROM
             \"Employees\"
          WHERE
             \"EmployeeID\"="." \'$input{empid}\'";
$ins = $db_handle->prepare($query);
$ins->execute;
while (@row = $ins->fetchrow) {
         $ln .= "<input value=$row[0]></input>\n";
         $fn .= "<input value=$row[1]></input>\n";
         $tl .= "<input value=$row[2]></input>\n";
         $tc .= "<input value=$row[3]></input>\n";
         $bd .= "<input value=$row[4]></input>\n";
         $hd .= "<input value=$row[5]></input>\n";
         $ad .= "<input value=$row[6]></input>\n";
         $ct .= "<input value=$row[7]></input>\n";
         $rg .= "<input value=$row[8]></input>\n";
         $pc .= "<input value=$row[9]></input>\n";
         $cy .= "<input value=$row[10]></input>\n";
         $hp .= "<input value=$row[11]></input>\n";
         $xt .= "<input value=$row[12]></input>\n";
         $nt .= "<input value=$row[13]></input>\n";
         $rt .= "<input value=$row[14]></input>\n";
                 }

Here is the form data I want to fill in with above values driven from the database :

Code:
<div class="container">
<form method=POST>
Select an employee to be updated and press FETCH:<select name=empid>$tt</select><br>
<input type=submit name=go value=FETCH>
Last Name :<input name=lastname><br>
First Name :<input name=firstname><br>
Title :<input name=title><br>
Title Of Courtesy :<input name=toc><br>
Birth Date :<input name=dob><br>
Hire Date :<input name=doh><br>
Address :<input name=address><br>
City :<input name=city><br>
Region :<input name=region><br>
Postal Code :<input name=pcode><br>
Country :<input name=country><br>
Home Phone :<input name=homephone><br>
Extension :<input name=ext><br>
Notes :<input name=notes><br>
Reports To :<select name=repto>$hh</select><br>
<input type=submit name=go value=UPDATE>
</div>
</form><hr>

Many thanks in advance for your kind help !!
Please note that I will post it on perlmonks as well.

Rgds
Terry
# 2  
Old 07-06-2014
This thread is a duplicate of Pop up confirmation box / perl cgi. This thread is closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cgi to dump xml data from form input field

Hi All, I am trying to write a shell script which takes parse the web form find the input field and dump the data of that field into one xml file. The form looks like, <input type="button" id="btnSave" value="Save" onclick="saveXmlData()"/> <form name="submitForm"... (1 Reply)
Discussion started by: jdp
1 Replies

2. Shell Programming and Scripting

CGI Perl : while loop in CGI perl

Hi Team, I am trying to connect to database(succeeded ) and print the records on the browser using while loop. But the elements of array are not displayed instead while loop is displayed directly. Instead of the below I can embed html statements in print but I am looking for the below style as I... (1 Reply)
Discussion started by: scriptscript
1 Replies

3. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

4. Shell Programming and Scripting

Perl cgi pages out of cgi-bin folder in WINDOWS

Hi team, I have a typical problem with cgi pages in apache webserver in WINDOWS I am able to execute(display) the pages that are saved in cgi-bin folder. But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder. Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies

5. Shell Programming and Scripting

CGI in Perl

Hi, Am unfamiliar with using CGI modules in Perl. Though i checked in few sites about CGI , i dint get a clear idea. Can anyone please explain me the purpose of these statements, it ll be very helpful to me #!/usr/bin/perl use CGI qw/:standard/; use Storable; use Data::Dumper; my... (1 Reply)
Discussion started by: irudayaraj
1 Replies

6. Shell Programming and Scripting

Table / Boxes Generation in PERL

Hi all, I was wondering, if there is any way to generate boxes/tables using perl to represent some data in better format. input : Name SAlary pranav 10000 ajay 5000 shri 15000 output : _________________________ |Name |Salary |... (3 Replies)
Discussion started by: PranavEcstasy
3 Replies

7. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

8. Shell Programming and Scripting

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies

9. Shell Programming and Scripting

Perl CGI.pm

my box is FreeBSD4.3 and I use Perl 5.0005_03. Here is the CGI script. test.cgi ...... if ($query->action eq 'detail') { ...... print $query->hidden('action', 'modify'); ...... } I found that the result of test.cgi?action=detail is not what I expected. the script does not... (4 Replies)
Discussion started by: tonyt
4 Replies

10. Programming

text boxes, radio buttons , check boxes in c++ on unix

Hi ! Please tell me how to get radio buttons, text boxes , check boxes , option buttons , pull down menus in C++ on Unix. I think it would be done using curses.h ..but that's all i know. TIA, Devyani. (3 Replies)
Discussion started by: devy8
3 Replies
Login or Register to Ask a Question