By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,933 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,933 IT Pros & Developers. It's quick & easy.

Truncated output using input type 'text' box

P: 4
I have a form requiring data input for all fields. When any field is left blank and the data is submitted, the cgi file generates a new form which is populated with data already input and an error message to fill in the missing data.

An anomaly occurs with the reprinted form. One field often requires input of more than one word from the original form. However, the reprinted form populates the text field with only the first word of the string.

To test this, please go to: http://www.caz-cc.com/members/away_scores.htm .
Enter a bunch of data in the fields leaving a couple of fields blank. In the "Course Played" field enter 3-4 words. Submit the data. The resulting reprinted form will repopulate each text field. However the Course Played field will populate with only the first word of the input string.

A snippet of the Perl used to repopulate the form is :
Expand|Select|Wrap|Line Numbers
  1. <td width="25%"><p align="left" class="bold">Course Played </p></td>
  2.                   <td width="55%"><div align="left"><input type="text" name="course" size="60" maxlength="30" value = $in{'course'}></div></td>
  3.                   <td width="20%"><p align="left" style="color:red">
  4. eoh
  5.  
  6.     #Write out error message if course is missing
  7. if($in{'course'} eq "")
  8. {print "Required field";}
  9. print <<"eoh";
  10. </p></td>
  11.  
What can I do to populate with the entire string??

Thanks much for your input!

Jack
Jul 25 '08 #1
Share this Question
Share on Google+
7 Replies


KevinADC
Expert 2.5K+
P: 4,059
try changing the maxlength attribute or just get rid of it:

maxlength="30"
Jul 25 '08 #2

P: 4
Thanks for the input Kevin. I deleted the maxlength attribute, but I get the same results. Any other suggestions?
Jul 26 '08 #3

eWish
Expert 100+
P: 971
Are you printing the exact same form each time? The reason I ask is that your form is being display first on a static HTML page and I would guess that the second time it is display is from within the perl script. If you have them print the exact same form from the same place instead of two different sources it should help you resolve your issue.

--Kevin
Jul 26 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
Thanks for the input Kevin. I deleted the maxlength attribute, but I get the same results. Any other suggestions?
Search through the perl code and find out where the problem is. Post your perl code it its not too long.
Jul 26 '08 #5

P: 4
Hi All,
The reprint is part of my cgi file. I simply copied the original html code from the linked page in my original post above and pasted it into place in my perl code. I them made necessary changes to print the error messages. As you suggested
Kevin, here is a copy of the entire perl code:


Expand|Select|Wrap|Line Numbers
  1.  !/usr/bin/perl -w
  2. #Submit "Away" scores
  3.  
  4. require "cgi-lib.pl";
  5. &ReadParse;
  6. $mailprog = '/usr/sbin/sendmail';
  7. print &PrintHeader;
  8.  
  9. #Check to see if any required fields are missing
  10.  
  11. #This line checks to see that all fields in form has been populated 
  12. #If any of that is true, the script will reprint the form and add error messages in all of the missing required fields.
  13.  
  14. if(($in{'number'} eq "") || ($in{'fname'} eq "") || ($in{'lname'} eq "") || ($in{'email'} eq "") || ($in{'course'} eq "") || ($in{'date'} eq "") || ($in{'slope'} eq "") || ($in{'rating'} eq "") || ($in{'adjust'} eq ""))
  15.  
  16. #Reprint the form with error messages!
  17. {
  18. print <<"eoh";
  19. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><!-- InstanceBegin template="/Templates/members_only.dwt" codeOutsideHTMLIsLocked="false" -->
  20.  
  21. <head>
  22. <!-- InstanceBeginEditable name="doctitle" -->
  23. <title>Cazenovia Country Club - A Private 18-Hole Golf Club</title>
  24. <!-- InstanceEndEditable -->
  25. <meta name="keywords" content="golf, 18-hole, course, private, country, club, Pro shop, Proshop, USGA, island, greens, fairway, bunker, sand, golf club, private golf club, golf course">
  26. <meta name="description" content="Welcome to Cazenovia Country Club, a private 18-hole championship golf course in Central New York.">
  27. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  28. <link href="../css/main.css" type="text/css" media="all" rel="stylesheet" />
  29. <link href="../css/multi_drop_menus_class.css" type="text/css" media="all" rel="stylesheet" />
  30.  
  31. <script language="JavaScript">
  32. <!-- 
  33. function open_new_window(url)
  34. new_window = window.open(url,'window_name','toolbar=1,menubar=1,resizable=1,scrollbars=1,dependent=0,status=1,width=950,height=600,left=350,top=25')
  35. }
  36. -->
  37. </script>
  38. <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  39. </head>
  40.  
  41. <body>
  42. <div id="outer_container">
  43.     <div id="date_holder">
  44.     <div class="date">
  45.             <script language="JavaScript" >
  46.                 var mydate=new Date()
  47.                 var year=mydate.getYear()
  48.                 if (year < 1000)
  49.                 year+=1900
  50.                 var day=mydate.getDay()
  51.                 var month=mydate.getMonth()
  52.                 var daym=mydate.getDate()
  53.                 if (daym<10)
  54.                 daym="0"+daym
  55.                 var dayarray=new Array("Sun","Mon","Tues","Wed","Thur","Fri","Sat")
  56.                 var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
  57.                 document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</font></small>")
  58.             </script></div>
  59.     </div><!--date_holder -->
  60.     <div id="header">    </div> <!-- header -->
  61.         <div id="menu">
  62.             <div class="multi_drop_menus">
  63.             <ul>
  64.                 <li><a href="../index.htm" title="Welcome to Cazenovia Country Club">Home</a></li>
  65.                 <li><a href="../members/member_news.htm" title="Member News">Member News</a></li>
  66.                 <li><a title="League Play &amp; Results">Leagues</a>
  67.                     <ul>
  68.                         <li><a href="../members/ladies_twilight.htm" title="Ladies Twilight League">Ladies Twilight</a></li>
  69.                         <li><a href="../members/mens_thursday.htm" title="Men's Thursday League">Men's Thursday</a></li>
  70.                         <li><a href="../members/ladies_18_hole.htm" title="Ladies 18-Hole">Ladies 18-Hole</a></li>
  71.                         <li><a href="../members/ringers/site_control_panel.html" title="Ladies Thursday Ringer">Ladies Ringer</a></li>
  72.                         <li><a href="../members/seniors.htm" title="Men Seniors">Men Seniors</a></li>
  73.                         <li><a href="../members/couples.htm" title="Friday Night Couples League">Friday Couples</a></li>
  74.                     </ul>
  75.                 </li>
  76.                 <li><a href="../members/events.htm" title="League Events">Event Results</a></li>
  77.                 <li><a href="http://www.nycom2.com/ccc/hcap.asp" title="Member Handicap">Handicap</a></li>
  78.                 <li><a href="../members/away_scores.htm" title="Enter Away Scores">Away Scores</a></li>
  79.             </ul>
  80.             </div> <!-- multi_drop_menus -->
  81.         </div> <!-- menu -->
  82.         <!-- InstanceBeginEditable name="main_contents" -->
  83.   <div id="main_contents">
  84.             <h1>Submit 18-Hole &quot;Away&quot; Scores</h1>
  85.               <p>This Away score form will be available for your convenience only from April - October. For winter scores, please save your score cards and enter scores in the club house in the spring. 
  86.               <span class="bold"><p style="color:#900">Please fill in all text boxes</p></span>
  87.  
  88.               <form action="http://www.caz-cc.com/cgi-bin/awayscores.cgi" method="post" name="Awayscores">
  89.               <input type="hidden" value="jgray1@twcny.rr.com" name="myemail" />
  90.                       <input type="hidden" value="cazproshop@alltel.net.com" name="proshop" />
  91.                       <input type="hidden" value="proshop@caz-cc.com" name="proshop2" />
  92.               <table width="100%"  border="0" cellspacing="5" cellpadding="0">
  93.  
  94.                 <tr>
  95.                   <td width="25%"><p align="left" class="bold">Member Number</p> </td>
  96.                   <td width="55%"><div align="left">
  97.                 <input type="text" name="number" size="12" maxlength="5" value = $in{'number'}></div></td>
  98.                   <td width="20%"><p align="left" style="color:red">
  99. eoh
  100.  
  101.     #Write out error message if member number is missing
  102. if($in{'number'} eq "")
  103. {print "Required field";}
  104. print <<"eoh";
  105. </p></td>
  106.                 </tr>
  107.                 <tr>
  108.                   <td width="25%"><p align="left" class="bold">First Name</p> </td>
  109.                   <td width="55%"><div align="left"><input type="text" name="fname" size="30" value = $in{'fname'}></div></td>
  110.                   <td width="20%"><p align="left" style="color:red"> 
  111. eoh
  112.  
  113.     #Write out error message if fname is missing
  114. if($in{'fname'} eq "")
  115. {print "Required field";}
  116. print <<"eoh";
  117. </p></td>
  118.                 </tr>
  119.                 <tr>
  120.                   <td width="25%"><p align="left" class="bold">Last Name </p></td>
  121.                   <td width="55%"><div align="left"><input type="text" name="lname" size="30" value = $in{'lname'}></div></td>
  122.                   <td width="20%"><p align="left" style="color:red"> 
  123. eoh
  124.  
  125.     #Write out error message if lname is missing
  126. if($in{'lname'} eq "")
  127. {print "Required field";}
  128. print <<"eoh";
  129. </p></td>
  130.                 </tr>
  131.                 <tr>
  132.                   <td width="25%"><p align="left" class="bold">Email Address<span style="color:#990000">*</span> </p></td>
  133.                   <td width="55%"><div align="left"><input type="text" name="email" size="40" value = $in{'email'}></div></td>
  134.                   <td width="20%"><p align="left" style="color:red">
  135. eoh
  136.  
  137.     #Write out error message if email is missing
  138. if($in{'email'} eq "")
  139. {print "Required field";}
  140. print <<"eoh";
  141. </p></td>
  142.                 </tr>
  143.                 <tr>
  144.                   <td width="25%"><p align="left" class="bold">Course Played </p></td>
  145.                   <td width="55%"><div align="left"><input type="text" name="course" size="60" value = $in{'course'}></div></td>
  146.                   <td width="20%"><p align="left" style="color:red">
  147. eoh
  148.  
  149.     #Write out error message if course is missing
  150. if($in{'course'} eq "")
  151. {print "Required field";}
  152. print <<"eoh";
  153. </p></td>
  154.                 </tr>
  155.                 <tr>
  156.                   <td width="25%"><p align="left" class="bold">Date Played <span style="font-size:12px">(mm/dd/yyyy)</span></p></td>
  157.                   <td width="55%"><div align="left"><input type="text" name="date" size="12" maxlength="10" value = $in{'date'}></div></td>
  158.                   <td width="20%"><p align="left" style="color:red">
  159. eoh
  160.  
  161.     #Write out error message if date is missing
  162. if($in{'date'} eq "")
  163. {print "Required field";}
  164. print <<"eoh";
  165. </p></td>
  166.                 </tr>
  167.                 <tr>
  168.                   <td width="25%"><p align="left" class="bold">Slope <span style="font-size:12px">(i.e., 120)</span></p></td>
  169.                   <td width="55%"><div align="left"><input type="text" name="slope" size="12" maxlength="3" value = $in{'slope'}></div></td>
  170.                   <td width="20%"><p align="left" style="color:red">
  171. eoh
  172.  
  173.     #Write out error message if slope is missing
  174. if($in{'slope'} eq "")
  175. {print "Required field";}
  176. print <<"eoh";
  177. </p></td>
  178.                 </tr>
  179.                 <tr>
  180.                   <td width="25%"><p align="left" class="bold">Course Rating <span style="font-size:12px">(i.e., 67.4)</span> </p></td>
  181.                   <td width="55%"><div align="left"><input type="text" name="rating" size="12" maxlength="4" value = $in{'rating'}></div></td>
  182.                   <td width="20%"><p align="left" style="color:red">
  183. eoh
  184.  
  185.     #Write out error message if rating is missing
  186. if($in{'rating'} eq "")
  187. {print "Required field";}
  188. print <<"eoh";
  189. </p></td>
  190.                 </tr>
  191.                 <tr>
  192.                   <td width="25%"><p align="left" class="bold">Adjusted Score<span style="color:#990000">**</span> </p></td>
  193.                   <td width="55%"><div align="left"><input type="text" name="adjust" size="12" maxlength="3" value = $in{'adjust'}></div></td>
  194.                   <td width="20%"><p align="left" style="color:red">
  195. eoh
  196.  
  197.     #Write out error message if adjust is missing
  198. if($in{'adjust'} eq "")
  199. {print "Required field";}
  200. print <<"eoh";
  201. </p></td>
  202.                 </tr>
  203.                 <tr>
  204.                   <td colspan="2"><p><br />
  205.                     * Email address is for confirmation purposes. Please submit your new email addresses to: &nbsp;&nbsp;&nbsp;<span style="font-size:14px"><a href="mailto:proshop@caz-cc.com">proshop@caz-cc.com<br />
  206.                       </a></span><br />
  207. **Adjusted score means stroke control applied</p></td>
  208.                   <td>&nbsp;</td>
  209.                 </tr>
  210.                 <tr>
  211.                   <td colspan="2">
  212.                   <div style="font-weight:bold">
  213.                     <p>Please present a valid scorecard with this information
  214.                    on it to the Cazenovia Pro Shop on your next visit.
  215.                     </p>
  216.                   </div></td>
  217.                   <td>&nbsp;</td>
  218.                 </tr>
  219.                 <tr>
  220.                   <td colspan="3"><div align="center">
  221.                     <input type="submit" name="Submit_Score" value="Submit Score" />&nbsp;&nbsp;&nbsp;<input name="Reset_Form" type="reset" value="Reset">
  222.                   </div></td>
  223.                 </tr>
  224.               </table></form>
  225.         </div><!-- InstanceEndEditable --><!-- main_contents -->
  226.         <div id="footer"><p>Copyright 2007 Cazenovia Country Club, Inc. <br />
  227. email: <a href="mailto:bizofc@caz-cc.com">bizofc@caz-cc.com </a><br />
  228. Phone (315) 655-8573 Fax (315) 655-3146 <br />
  229. 3711 Number Nine Road., PO Box 319, Cazenovia, New York 13035<br />
  230. Graphics by: <a href="http://www.gilmoregraphics.com" target="_blank">Gilmore Graphics, Inc</a><br />
  231. Contact Webmaster <a href="mailto:jgray1@twcny.rr.com?subject=CCC web inquiry">Jack Gray </a></p></div> 
  232.         <!--footer -->
  233. </div> <!-- outer_container -->
  234. </body>
  235. <!-- InstanceEnd --></html>
  236. eoh
  237. }
  238. else
  239. {
  240. #unless (-e $mailprog)
  241. #{
  242. #print <<"eohtml";
  243. #<html><body>
  244. #<H1>Cannot find mail program</H1>
  245. #</body></html>
  246. #eohtml
  247. #exit(0);
  248. #}
  249.  
  250.  
  251. #Create HTML page
  252. {
  253. print <<"eohtml";
  254. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  255. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  256. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><!-- InstanceBegin template="/Templates/members_only.dwt" codeOutsideHTMLIsLocked="false" -->
  257.  
  258. <head>
  259. <!-- InstanceBeginEditable name="doctitle" -->
  260. <title>Cazenovia Country Club - A Private 18-Hole Golf Club</title>
  261. <!-- InstanceEndEditable -->
  262. <meta name="keywords" content="golf, 18-hole, course, private, country, club, Pro shop, Proshop, USGA, island, greens, fairway, bunker, sand, golf club, private golf club, golf course" />
  263. <meta name="description" content="Welcome to Cazenovia Country Club, a private 18-hole championship golf course in Central New York." />
  264. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  265. <link href="../css/main.css" type="text/css" media="all" rel="stylesheet" />
  266. <link href="../css/multi_drop_menus_class.css" type="text/css" media="all" rel="stylesheet" />
  267.  
  268. <script language="JavaScript" type="text/javascript">
  269. <!--
  270. function MM_jumpMenu(targ,selObj,restore){ //v3.0
  271.   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  272.   if (restore) selObj.selectedIndex=0;
  273. function open_new_window(url)
  274. new_window = window.open(url,'window_name','toolbar=1,menubar=1,resizable=1,scrollbars=1,dependent=0,status=1,width=950,height=600,left=350,top=25')
  275. }
  276. -->
  277. </script>
  278. <!-- The line below starts the conditional comment -->
  279.  <!--[if lt IE 7]>
  280.   <style type="text/css">
  281.    body {behavior: url(/css/csshover.htc);}
  282.   </style>
  283.  <![endif]--> <!-- This ends the conditional comment -->
  284. <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  285. </head>
  286.  
  287. <body>
  288. <div id="outer_container">
  289.     <div id="date_holder">
  290.     <div class="date">
  291.             <script language="JavaScript" type="text/javascript">
  292.                 var mydate=new Date()
  293.                 var year=mydate.getYear()
  294.                 if (year < 1000)
  295.                 year+=1900
  296.                 var day=mydate.getDay()
  297.                 var month=mydate.getMonth()
  298.                 var daym=mydate.getDate()
  299.                 if (daym<10)
  300.                 daym="0"+daym
  301.                 var dayarray=new Array("Sun","Mon","Tues","Wed","Thur","Fri","Sat")
  302.                 var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
  303.                 document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"")
  304.             </script></div>
  305.     </div><!--date_holder -->
  306.     <div id="header">    </div> <!-- header -->
  307.         <div id="menu">
  308.             <div class="multi_drop_menus">
  309.             <ul>
  310.                 <li><a href="../index.htm" title="Welcome to Cazenovia Country Club">Home</a></li>
  311.                 <li><a href="../members/member_news.htm" title="Member News">Member News</a></li>
  312.                 <li><a title="League Play &amp; Results">Leagues</a>
  313.                     <ul>
  314.                         <li><a href="../members/ladies_twilight.htm" title="Ladies Twilight League">Ladies Twilight</a></li>
  315.                         <li><a href="../members/mens_thursday.htm" title="Men's Thursday League">Men's Thursday</a></li>
  316.                         <li><a href="../members/ladies_18_hole.htm" title="Ladies 18-Hole">Ladies 18-Hole</a></li>
  317.                         <li><a href="../members/ringers/site_control_panel.html" title="Ladies Thursday Ringer">Ladies Ringer</a></li>
  318.                         <li><a href="../members/seniors.htm" title="Men Seniors">Men Seniors</a></li>
  319.                         <li><a href="../members/couples.htm" title="Friday Night Couples League">Friday Couples</a></li>
  320.                     </ul>
  321.                 </li>
  322.                 <li><a href="../members/events.htm" title="League Events">Event Results</a></li>
  323.                 <li><a href="http://www.nycom2.com/ccc/hcap.asp" title="Member Handicap">Handicap</a></li>
  324.                 <li><a href="../members/away_scores.htm" title="Enter Away Scores">Away Scores</a></li>
  325.             </ul>
  326.             </div> <!-- multi_drop_menus -->
  327.         </div> <!-- menu -->
  328.         <!-- InstanceBeginEditable name="main_contents" -->
  329.   <div id="main_contents">
  330.               <h1>Cazenovia Country Club <br /><span class="h1small">Away Scores Response</span></h1>
  331.             <p>Thank you $in{'fname'}, for submitting your score for your round at $in{'course'}!<br />
  332.           Your score(s) are being directed to the pro-shop staff for entry into our handicap computer system.<br />
  333.           You will receive an email confirmation of the data you have submitted.<br />
  334.               If you have more scores to submit, please click <a href="../members/away_scores.htm" target="_self">HERE</a>.</p> 
  335.  
  336.         </div><!-- InstanceEndEditable --><!-- main_contents -->
  337.         <div id="footer"><p>Copyright 2007 Cazenovia Country Club, Inc. <br />
  338. email: <a href="mailto:bizofc@caz-cc.com">bizofc@caz-cc.com </a><br />
  339. Phone (315) 655-8573 Fax (315) 655-3146 <br />
  340. 3711 Number Nine Road., PO Box 319, Cazenovia, New York 13035<br />
  341. Graphics by: <a href="http://www.gilmoregraphics.com" target="_blank">Gilmore Graphics, Inc</a><br />
  342. Contact Webmaster <a href="mailto:jgray1@twcny.rr.com?subject=CCC web inquiry">Jack Gray </a></p></div> 
  343.         <!--footer -->
  344. </div> <!-- outer_container -->
  345. </body>
  346. <!-- InstanceEnd --></html>
  347. eohtml
  348. }
  349. #Mail confirmation
  350. open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";
  351. print MAIL "To: $in{'proshop'}\n";
  352. print MAIL "To: $in{'proshop2'}\n";
  353. print MAIL "cc: $in{'email'}\n";
  354. print MAIL "Reply-To: $in{'proshop'}\n";
  355. print MAIL "From: $in{'proshop'}\n";
  356. print MAIL "Subject: Away Score Submission\n\n";
  357. print MAIL "Dear $in{'fname'}:\n";
  358. print MAIL "You have furnished us with the following away score submission:\n\n";
  359. print MAIL "Member number: $in{'number'}\n";
  360. print MAIL "Play date: $in{'date'}\n";
  361. print MAIL "Course: $in{'course'}\n";
  362. print MAIL "Slope: $in{'slope'}\n";
  363. print MAIL "Rating: $in{'rating'}\n";
  364. print MAIL "Adjusted score: $in{'adjust'}\n\n";
  365. print MAIL "This information will be reviewed for accuracy and, if found correct, will be entered into the CCC Handicap system. Please be sure to present your score card to the club pro on your next visit.\n\n";
  366. print MAIL "Thank you!\n\n";
  367. print MAIL "Handicap Committee\n\n";
  368. print MAIL "This is an autoresponse email. Please do not respond.\n";
  369. close(MAIL);
  370. }
  371. #End of program
Jul 26 '08 #6

KevinADC
Expert 2.5K+
P: 4,059
I feel a bit stupid now. I believe Travis on tek-tips pin-pointed the problem. You need to add the quotes in the text tag around the value:

Expand|Select|Wrap|Line Numbers
  1. maxlength="30" value = $in{'course'}>
should be:

Expand|Select|Wrap|Line Numbers
  1. maxlength="30" value ="$in{'course'}">
I should have noticed that myself. Give Travis a star on Tek-tips if that proves to be the source of the problem, which I am confident it will.
Jul 26 '08 #7

P: 4
I feel a bit stupid now. I believe Travis on tek-tips pin-pointed the problem. You need to add the quotes in the text tag around the value:

Expand|Select|Wrap|Line Numbers
  1. maxlength="30" value = $in{'course'}>
should be:

Expand|Select|Wrap|Line Numbers
  1. maxlength="30" value ="$in{'course'}">
I should have noticed that myself. Give Travis a star on Tek-tips if that proves to be the source of the problem, which I am confident it will.
Thanks Kevin for your help! I got it from Travis and I feel like a fool. Such a simple solution, yet illusive.

Jack
Jul 26 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.