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 :
$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 :
<form method=POST> Select an employee to be updated and press FETCH:<select name=empid>$t +t</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 :
# 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 :
<div class="container"> <form method=POST> Select an employee to be updated and press FETCH:<select name=empid>$t +t</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 perlguru as well. Rgds Terry

In reply to How to get input text boxes populated by terrykhatri

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.