Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Forms and interaction in CGI

by khelben (Initiate)
on Sep 11, 2003 at 09:03 UTC ( #290621=perlquestion: print w/replies, xml ) Need Help??

khelben has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
some days ago I asked for help with long strings. Thank You a lot.
But how can I get some interaction?

I have red something about formulars in Perl/CGI, but i have not got useful examples for my problems. I know how to do this in c++ with X/Windows, but not in Perl/CGI on the Web(browser)

I need a value (integer >0) stored in a variable. Like here:
Number(1..20000)?:_________

Then some "Radiobuttons" with a text on each button and 1 row where I can choose 1 from n possibilities and another row where I can choose m from m possibilities.
Then a button to say, that all the input has been done an the script can compute a result and last not least an outputtextbox for the result with the possibility tho have scrollbars.

Do You know a good source of examples for some code or do You have some useful help for me?

Best wishes and thanks,
Roman

update (broquaint): title change (was Formulars and some interaction)

Replies are listed 'Best First'.
Re: Forms and interaction in CGI
by smitz (Chaplain) on Sep 11, 2003 at 09:35 UTC
    Hallo Roman,

    You say you need some forms and radio buttons, are you sure you are not looking to print HTML?
    Have a look at CGI.pm, a tool which will help you print out HTML and parse submitted HTML forms.

    I need a value (integer >0) stored in a variable. Like here:
    Number(1..20000)?:_________


    Im not quite sure what you mean here, you need an integer stored in a variable?
    $variable = 42;
    Can you rephrase?

    In any case, examples of doing this kind of thing, if I have understood your question correctly, can be found in abundance in the CGI.pm documentation.

    Smitz
      This works good, thanks!
      use CGI qw/:standard/; print header, start_html('Simple Script'), h1('Simple Script'), start_form, "What's your name? ",textfield('name'),p, "What's the combination?", checkbox_group(-name=>'words', -values=>['eenie','meenie','minie','moe'], -defaults=>['eenie','moe']),p, "What's your favorite color?", popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']),p, submit, end_form, hr,"\n"; if (param) { print "Your name is ",em(param('name')),p, "The keywords are: ",em(join(", ",param('words'))),p, "Your favorite color is ",em(param('color')),".\n"; } print end_html;
      Im not quite sure what you mean here, you need an integer stored in a variable?
      $variable = 42;
      Can you rephrase?


      Maybe: "What's your name? ",textfield('name'),p,
      Here i need a number.
      Can I change the text of the button "Submit Query"?
      How can I put the output in a textfield with scrollbars?

      CU
      Roman

        A textfield will take text including numbers, it is up to you to check if the user submitted a number on the server. As for changing the button text:

        use CGI ':standard'; print submit( suggestion => 'RTFM' ); __DATA__ <input type="submit" name="suggestion" value="RTFM" />

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2022-09-30 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?