Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

CGI form help with buttons

by SteveVsPerl (Initiate)
on Jul 28, 2011 at 17:00 UTC ( [id://917298]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks,

I am new to perl and my first task is to create form that will either: allow the user to select an existing file and edit it, or create a new one.

The whole button situation I am at a complete loss. I have no idea how to get the buttons to allow the user to navigate between the pages.

Without having to post my entire .cgi; is there a common way to present buttons in CGI that open new pages. In my situation one page would be a form populated by a file that the user would select from a dropdown box. And the other page would be an empty form.

I have been actively looking for a solution for this for about two days and I'm about to go insane.

Replies are listed 'Best First'.
Re: CGI form help with buttons
by luis.roca (Deacon) on Jul 28, 2011 at 17:18 UTC

    Hi Steve,

    It sounds like what you are trying to build is a website content management system — right? (To update articles/FAQs, images etc.) If that's the case and you're new to Perl you may want to look at Melody.

    However, if you need a broader form solution to edit various file formats you can take a look at CGI::FormBuilder which has been around for a while and has lots of tutorials available.

    Also, take a look at CGI 101. The first 5 chapters are available online and will help you a lot without even having to buy the book.

    Good luck! Luis


    "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." — Don Quixote

      Actually what I'm making is a site users and use to modify "watch-lists." On the first page I prompt them with a drop-down-list of the watch-lists from a specified directory. The user either selects one and clicks an "open" button or clicks a "new" button to start a new one. The only thing in the file is a list of email addresses and a list of tags being "watched."

      At first I had a submit button that opened the selected file. But Now that I'm trying to add a second button to create a new one I'm at a loss.

      Melody isn't quite what I'm looking for, thanks though. I've already read the CGI101 it was very helpful. Formbuilder does look like it will do the trick. I look forward to rewriting my 200 lines of code. =)

        Before you start a rewrite, and if you are planning a rewrite, consider the decade we're in and what tools are available. While it's still used, CGI is an old technology. It has served the Internet well, was as ubiquitous as hydrogen in the early days, and is still maintained and nowadays but it's past its prime and there are more modern tools that allow you to develop with less effort.

        Take on a small project with Mojolicious::Lite, and thank yourself for arriving at sanity later. For bigger projects, Mojolicious, Catalyst, Dancer, etc.

        There will be a learning curve getting used to thinking in terms of Model/View/Controller, but once you get past the initial investment in learning you will be amazed at how much easier things have become.


        Dave

Re: CGI form help with buttons
by thunders (Priest) on Jul 29, 2011 at 19:52 UTC

    This is mostly an HTML issue. There are a few ways you can do this.

    You can create an image that looks like a button, and hyperlink it to the page you want to go to

    <a href="/cgi-bin/my_script.pl?param1=foo"><img src="button_foo.png">< +/a>

    If you know any CSS you could use a similar approach, but with a DIV tag styled to look like a button

    You could create a small form and use a submit button

    <form action="/cgi-bin/myscript.pl" method="POST"> <input type="hidden" name="param1" value="foo"/> <input type="submit" value="Go to Script"/> </form>

    You can also use Javascript on a Button tag

    <button onClick="window.location='http://mysite.com/cgi-bin/my_script. +pl?param1=foo'">Go to Script</button>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-20 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found