Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

HTML Fieldset messing up self referencing CGI?

by Popcorn Dave (Abbot)
on Feb 20, 2008 at 22:15 UTC ( #669120=perlquestion: print w/replies, xml ) Need Help??
Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I've hit a wall with this problem and I'm not sure if it's something I've inadvertently done or if CGI.pm is having a problem with generating the HTML code.

I'm generating a HTML form using a combination of OO CGI and print statements because as far as I can tell CGI.pm doesn't support the fieldset and label tags as of yet unless I use CGI::FormBuilder. As I'm trying to do my error checking right in Perl I'm not sure that using that module is the way to go since it does the error checking in JavaScript and I'm just setting CSS options to denote unfilled required fields.

Given this pared down code snippet:

sub html_form{ print qq( <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="generator" content= "HTML Tidy for Windows (vers 24 May 2007), see www.w3.org" /> <title>Wright Popcorn &amp; Nut Company</title> <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> <script src="checkbox.js" language="javascript" type= "text/javascript"> </script> <link rel="STYLESHEET" href="cart.css" type="text/css" /> </head> <body> <div id="header"> <h1> Order your Pink Popcorn Here!</H1> <H2>I want to order: &nbsp; &nbsp;Quantity &nbsp; <INPUT TYPE="text" NAME="quan" VALUE="1" MAXLENGTH="2" SIZE="2"> <INPUT NAME="size" TYPE="radio" CHECKED VALUE="50">50/cs <INPUT NAME="size" TYPE="radio" VALUE="100">100/cs </H2> </div> <div>); print $query->start_form(-name => 'scart'); print qq! <div id="center"> <fieldset> <legend>Billing Informtion</legend>!; print qq! <p><label for="billname" class=$id_check{BillName2}>Name</labe +l> <input id="billname2" name="billname2" type="text" value=$params{billname2} ></p> <p><label for="billaddress1" class=$id_check{billaddress14}>Ad +dress</label> <input id= "billaddress14" name="billaddress14" type="text" /></p> <p class="submit"><input value="Place my Order!" type="submit" + /></p> </fieldset> </div>!; print $query->end_form; print qq( </div> </body> </html> ); }

when I put in just the first paramter, it returns the HTML as I would expect, but only the first part of a possible multi part paramter. For example, if I put blah blah in the name field, after the submit just the first blah is returned in the field. However Data::Dumper shows that blah blah is passed as a parameter.

Anybody have a clue why it seems to be clipping the data there?

Update: As <a href="http://www.perlmonks.org/?node_id=522408>olus pointed out I didn't have the double quotes around the value, but it turns out that I didn't need the value there anyway. Apparently the input id and name pieces takes care of that. If I'm incorrect in that reasoning, please let me know.


Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

I would love to change the world, but they won't give me the source code

Replies are listed 'Best First'.
Re: HTML Fieldset messing up self referencing CGI?
by olus (Curate) on Feb 20, 2008 at 22:47 UTC

    I'm not sure I fully understand your question, and usually use Template to take care of the HTML parts, but I notice you don't have the double quotes around the value of the input field billname2. What happens when there are no double quotes is that, if the value is a space separated string, only the first word is considered. So 'blah blah' will be considered as only 'blah'.

    Update: On your update. You set the attribute 'value' if you want to show some default value when displaying the form. If you do not set the 'value' attribute, the form displays an empty text input field. Either way, whatever a user writes in that field will be passed to the script when the form is submited.

      Thank you! I can't believe I overlooked something so simple. Pardon me while I go wipe the egg off my face. :)


      Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

      I would love to change the world, but they won't give me the source code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://669120]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2019-04-19 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (107 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!