Truncated output using input type 'text' box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jack Gray
    New Member
    • Jul 2008
    • 4

    Truncated output using input type 'text' box

    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 :
    Code:
    <td width="25%"><p align="left" class="bold">Course Played </p></td>
                      <td width="55%"><div align="left"><input type="text" name="course" size="60" maxlength="30" value = $in{'course'}></div></td>
                      <td width="20%"><p align="left" style="color:red">
    eoh
    
    	#Write out error message if course is missing
    if($in{'course'} eq "")
    {print "Required field";}
    print <<"eoh";
    </p></td>
    What can I do to populate with the entire string??

    Thanks much for your input!

    Jack
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    try changing the maxlength attribute or just get rid of it:

    maxlength="30"

    Comment

    • Jack Gray
      New Member
      • Jul 2008
      • 4

      #3
      Thanks for the input Kevin. I deleted the maxlength attribute, but I get the same results. Any other suggestions?

      Comment

      • eWish
        Recognized Expert Contributor
        • Jul 2007
        • 973

        #4
        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

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          Originally posted by Jack Gray
          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.

          Comment

          • Jack Gray
            New Member
            • Jul 2008
            • 4

            #6
            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:


            Code:
             !/usr/bin/perl -w
            #Submit "Away" scores
            
            require "cgi-lib.pl";
            &ReadParse;
            $mailprog = '/usr/sbin/sendmail';
            print &PrintHeader;
            
            #Check to see if any required fields are missing
            
            #This line checks to see that all fields in form has been populated 
            #If any of that is true, the script will reprint the form and add error messages in all of the missing required fields.
            
            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 ""))
            
            #Reprint the form with error messages!
            {
            print <<"eoh";
            <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><!-- InstanceBegin template="/Templates/members_only.dwt" codeOutsideHTMLIsLocked="false" -->
            
            <head>
            <!-- InstanceBeginEditable name="doctitle" -->
            <title>Cazenovia Country Club - A Private 18-Hole Golf Club</title>
            <!-- InstanceEndEditable -->
            <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">
            <meta name="description" content="Welcome to Cazenovia Country Club, a private 18-hole championship golf course in Central New York.">
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <link href="../css/main.css" type="text/css" media="all" rel="stylesheet" />
            <link href="../css/multi_drop_menus_class.css" type="text/css" media="all" rel="stylesheet" />
            
            <script language="JavaScript">
            <!-- 
            function open_new_window(url)
            { 
            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')
            }
            -->
            </script>
            <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
            </head>
            
            <body>
            <div id="outer_container">
            	<div id="date_holder">
            	<div class="date">
            			<script language="JavaScript" >
            				var mydate=new Date()
            				var year=mydate.getYear()
            				if (year < 1000)
            				year+=1900
            				var day=mydate.getDay()
            				var month=mydate.getMonth()
            				var daym=mydate.getDate()
            				if (daym<10)
            				daym="0"+daym
            				var dayarray=new Array("Sun","Mon","Tues","Wed","Thur","Fri","Sat")
            				var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
            				document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</font></small>")
            			</script></div>
            	</div><!--date_holder -->
            	<div id="header">	</div> <!-- header -->
            		<div id="menu">
            			<div class="multi_drop_menus">
            			<ul>
            				<li><a href="../index.htm" title="Welcome to Cazenovia Country Club">Home</a></li>
            				<li><a href="../members/member_news.htm" title="Member News">Member News</a></li>
            				<li><a title="League Play &amp; Results">Leagues</a>
            					<ul>
            						<li><a href="../members/ladies_twilight.htm" title="Ladies Twilight League">Ladies Twilight</a></li>
            						<li><a href="../members/mens_thursday.htm" title="Men's Thursday League">Men's Thursday</a></li>
            						<li><a href="../members/ladies_18_hole.htm" title="Ladies 18-Hole">Ladies 18-Hole</a></li>
            						<li><a href="../members/ringers/site_control_panel.html" title="Ladies Thursday Ringer">Ladies Ringer</a></li>
            						<li><a href="../members/seniors.htm" title="Men Seniors">Men Seniors</a></li>
            						<li><a href="../members/couples.htm" title="Friday Night Couples League">Friday Couples</a></li>
            					</ul>
            				</li>
            				<li><a href="../members/events.htm" title="League Events">Event Results</a></li>
            				<li><a href="http://www.nycom2.com/ccc/hcap.asp" title="Member Handicap">Handicap</a></li>
            				<li><a href="../members/away_scores.htm" title="Enter Away Scores">Away Scores</a></li>
            			</ul>
            			</div> <!-- multi_drop_menus -->
            		</div> <!-- menu -->
            		<!-- InstanceBeginEditable name="main_contents" -->
              <div id="main_contents">
            			<h1>Submit 18-Hole &quot;Away&quot; Scores</h1>
            			  <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. 
            			  <span class="bold"><p style="color:#900">Please fill in all text boxes</p></span>
            			  
            			  <form action="http://www.caz-cc.com/cgi-bin/awayscores.cgi" method="post" name="Awayscores">
            			  <input type="hidden" value="jgray1@twcny.rr.com" name="myemail" />
            					  <input type="hidden" value="cazproshop@alltel.net.com" name="proshop" />
            					  <input type="hidden" value="proshop@caz-cc.com" name="proshop2" />
                          <table width="100%"  border="0" cellspacing="5" cellpadding="0">
                            
                            <tr>
                              <td width="25%"><p align="left" class="bold">Member Number</p> </td>
                              <td width="55%"><div align="left">
            				<input type="text" name="number" size="12" maxlength="5" value = $in{'number'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if member number is missing
            if($in{'number'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">First Name</p> </td>
                              <td width="55%"><div align="left"><input type="text" name="fname" size="30" value = $in{'fname'}></div></td>
                              <td width="20%"><p align="left" style="color:red"> 
            eoh
            
            	#Write out error message if fname is missing
            if($in{'fname'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Last Name </p></td>
                              <td width="55%"><div align="left"><input type="text" name="lname" size="30" value = $in{'lname'}></div></td>
                              <td width="20%"><p align="left" style="color:red"> 
            eoh
            
            	#Write out error message if lname is missing
            if($in{'lname'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Email Address<span style="color:#990000">*</span> </p></td>
                              <td width="55%"><div align="left"><input type="text" name="email" size="40" value = $in{'email'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if email is missing
            if($in{'email'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Course Played </p></td>
                              <td width="55%"><div align="left"><input type="text" name="course" size="60" value = $in{'course'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if course is missing
            if($in{'course'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Date Played <span style="font-size:12px">(mm/dd/yyyy)</span></p></td>
                              <td width="55%"><div align="left"><input type="text" name="date" size="12" maxlength="10" value = $in{'date'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if date is missing
            if($in{'date'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Slope <span style="font-size:12px">(i.e., 120)</span></p></td>
                              <td width="55%"><div align="left"><input type="text" name="slope" size="12" maxlength="3" value = $in{'slope'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if slope is missing
            if($in{'slope'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Course Rating <span style="font-size:12px">(i.e., 67.4)</span> </p></td>
                              <td width="55%"><div align="left"><input type="text" name="rating" size="12" maxlength="4" value = $in{'rating'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if rating is missing
            if($in{'rating'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td width="25%"><p align="left" class="bold">Adjusted Score<span style="color:#990000">**</span> </p></td>
                              <td width="55%"><div align="left"><input type="text" name="adjust" size="12" maxlength="3" value = $in{'adjust'}></div></td>
                              <td width="20%"><p align="left" style="color:red">
            eoh
            
            	#Write out error message if adjust is missing
            if($in{'adjust'} eq "")
            {print "Required field";}
            print <<"eoh";
            </p></td>
                            </tr>
                            <tr>
                              <td colspan="2"><p><br />
                                * 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 />
                                  </a></span><br />
            **Adjusted score means stroke control applied</p></td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td colspan="2">
                              <div style="font-weight:bold">
                                <p>Please present a valid scorecard with this information
            				   on it to the Cazenovia Pro Shop on your next visit.
                                </p>
                              </div></td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td colspan="3"><div align="center">
                                <input type="submit" name="Submit_Score" value="Submit Score" />&nbsp;&nbsp;&nbsp;<input name="Reset_Form" type="reset" value="Reset">
                              </div></td>
                            </tr>
                          </table></form>
                    </div><!-- InstanceEndEditable --><!-- main_contents -->
            		<div id="footer"><p>Copyright 2007 Cazenovia Country Club, Inc. <br />
            email: <a href="mailto:bizofc@caz-cc.com">bizofc@caz-cc.com </a><br />
            Phone (315) 655-8573 Fax (315) 655-3146 <br />
            3711 Number Nine Road., PO Box 319, Cazenovia, New York 13035<br />
            Graphics by: <a href="http://www.gilmoregraphics.com" target="_blank">Gilmore Graphics, Inc</a><br />
            Contact Webmaster <a href="mailto:jgray1@twcny.rr.com?subject=CCC web inquiry">Jack Gray </a></p></div> 
            		<!--footer -->
            </div> <!-- outer_container -->
            </body>
            <!-- InstanceEnd --></html>
            eoh
            }
            else
            {
            #unless (-e $mailprog)
            #{
            #print <<"eohtml";
            #<html><body>
            #<H1>Cannot find mail program</H1>
            #</body></html>
            #eohtml
            #exit(0);
            #}
            
            
            #Create HTML page
            {
            print <<"eohtml";
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><!-- InstanceBegin template="/Templates/members_only.dwt" codeOutsideHTMLIsLocked="false" -->
            
            <head>
            <!-- InstanceBeginEditable name="doctitle" -->
            <title>Cazenovia Country Club - A Private 18-Hole Golf Club</title>
            <!-- InstanceEndEditable -->
            <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" />
            <meta name="description" content="Welcome to Cazenovia Country Club, a private 18-hole championship golf course in Central New York." />
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <link href="../css/main.css" type="text/css" media="all" rel="stylesheet" />
            <link href="../css/multi_drop_menus_class.css" type="text/css" media="all" rel="stylesheet" />
            
            <script language="JavaScript" type="text/javascript">
            <!--
            function MM_jumpMenu(targ,selObj,restore){ //v3.0
              eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
              if (restore) selObj.selectedIndex=0;
            } 
            function open_new_window(url)
            { 
            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')
            }
            -->
            </script>
            <!-- The line below starts the conditional comment -->
             <!--[if lt IE 7]>
              <style type="text/css">
               body {behavior: url(/css/csshover.htc);}
              </style>
             <![endif]--> <!-- This ends the conditional comment -->
            <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
            </head>
            
            <body>
            <div id="outer_container">
            	<div id="date_holder">
            	<div class="date">
            			<script language="JavaScript" type="text/javascript">
            				var mydate=new Date()
            				var year=mydate.getYear()
            				if (year < 1000)
            				year+=1900
            				var day=mydate.getDay()
            				var month=mydate.getMonth()
            				var daym=mydate.getDate()
            				if (daym<10)
            				daym="0"+daym
            				var dayarray=new Array("Sun","Mon","Tues","Wed","Thur","Fri","Sat")
            				var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
            				document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"")
            			</script></div>
            	</div><!--date_holder -->
            	<div id="header">	</div> <!-- header -->
            		<div id="menu">
            			<div class="multi_drop_menus">
            			<ul>
            				<li><a href="../index.htm" title="Welcome to Cazenovia Country Club">Home</a></li>
            				<li><a href="../members/member_news.htm" title="Member News">Member News</a></li>
            				<li><a title="League Play &amp; Results">Leagues</a>
            					<ul>
            						<li><a href="../members/ladies_twilight.htm" title="Ladies Twilight League">Ladies Twilight</a></li>
            						<li><a href="../members/mens_thursday.htm" title="Men's Thursday League">Men's Thursday</a></li>
            						<li><a href="../members/ladies_18_hole.htm" title="Ladies 18-Hole">Ladies 18-Hole</a></li>
            						<li><a href="../members/ringers/site_control_panel.html" title="Ladies Thursday Ringer">Ladies Ringer</a></li>
            						<li><a href="../members/seniors.htm" title="Men Seniors">Men Seniors</a></li>
            						<li><a href="../members/couples.htm" title="Friday Night Couples League">Friday Couples</a></li>
            					</ul>
            				</li>
            				<li><a href="../members/events.htm" title="League Events">Event Results</a></li>
            				<li><a href="http://www.nycom2.com/ccc/hcap.asp" title="Member Handicap">Handicap</a></li>
            				<li><a href="../members/away_scores.htm" title="Enter Away Scores">Away Scores</a></li>
            			</ul>
            			</div> <!-- multi_drop_menus -->
            		</div> <!-- menu -->
            		<!-- InstanceBeginEditable name="main_contents" -->
              <div id="main_contents">
              			<h1>Cazenovia Country Club <br /><span class="h1small">Away Scores Response</span></h1>
            			<p>Thank you $in{'fname'}, for submitting your score for your round at $in{'course'}!<br />
            		  Your score(s) are being directed to the pro-shop staff for entry into our handicap computer system.<br />
            		  You will receive an email confirmation of the data you have submitted.<br />
                          If you have more scores to submit, please click <a href="../members/away_scores.htm" target="_self">HERE</a>.</p> 
                          
                    </div><!-- InstanceEndEditable --><!-- main_contents -->
            		<div id="footer"><p>Copyright 2007 Cazenovia Country Club, Inc. <br />
            email: <a href="mailto:bizofc@caz-cc.com">bizofc@caz-cc.com </a><br />
            Phone (315) 655-8573 Fax (315) 655-3146 <br />
            3711 Number Nine Road., PO Box 319, Cazenovia, New York 13035<br />
            Graphics by: <a href="http://www.gilmoregraphics.com" target="_blank">Gilmore Graphics, Inc</a><br />
            Contact Webmaster <a href="mailto:jgray1@twcny.rr.com?subject=CCC web inquiry">Jack Gray </a></p></div> 
            		<!--footer -->
            </div> <!-- outer_container -->
            </body>
            <!-- InstanceEnd --></html>
            eohtml
            }
            #Mail confirmation
            open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";
            print MAIL "To: $in{'proshop'}\n";
            print MAIL "To: $in{'proshop2'}\n";
            print MAIL "cc: $in{'email'}\n";
            print MAIL "Reply-To: $in{'proshop'}\n";
            print MAIL "From: $in{'proshop'}\n";
            print MAIL "Subject: Away Score Submission\n\n";
            print MAIL "Dear $in{'fname'}:\n";
            print MAIL "You have furnished us with the following away score submission:\n\n";
            print MAIL "Member number: $in{'number'}\n";
            print MAIL "Play date: $in{'date'}\n";
            print MAIL "Course: $in{'course'}\n";
            print MAIL "Slope: $in{'slope'}\n";
            print MAIL "Rating: $in{'rating'}\n";
            print MAIL "Adjusted score: $in{'adjust'}\n\n";
            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";
            print MAIL "Thank you!\n\n";
            print MAIL "Handicap Committee\n\n";
            print MAIL "This is an autoresponse email. Please do not respond.\n";
            close(MAIL);
            }
            #End of program

            Comment

            • KevinADC
              Recognized Expert Specialist
              • Jan 2007
              • 4092

              #7
              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:

              Code:
              maxlength="30" value = $in{'course'}>
              should be:

              Code:
              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.

              Comment

              • Jack Gray
                New Member
                • Jul 2008
                • 4

                #8
                Originally posted by KevinADC
                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:

                Code:
                maxlength="30" value = $in{'course'}>
                should be:

                Code:
                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

                Comment

                Working...