http://qs321.pair.com?node_id=200626

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

I run a small business in which I build very customized computers for home and business users (a lot of gamers, actually), and I want to add some functionality to my website by providing a way for users to have a list of available options, selectable by radio button and divided by category. I then want the price to be updated upon the click of a button.

The problem is, I have almost no idea how to go about doing this. I've moved all of my HTML from the original webpage into acceptable Perl format, but now I've got the issue of creating the CGI to do this. I thought something like the following would be good for where the price actually is stated:
if ($opcost = 0) { print "Go to the Options section to calculate!"; } else { print $price; }
Basically, I want the following:
I've worked some with HTML forms and Perl before, but I do not yet understand how to work with things like radio buttons (what values they return, whether to use POST or GET depending on situation), even though I've read that portion of the Llama. I understand that this should be a pretty simple thing to do, but I need help in assembling the parts and understanding.

Thanks in advance for the help!

Foncé

Replies are listed 'Best First'.
Re: Price updating script ideas
by spartacus9 (Beadle) on Sep 25, 2002 at 14:24 UTC
    The problem is in how you structured your "if ($opcost = 0)" statement. when you declare "if ($opcost = 0)", you are actually setting the value of $opcost to zero, not checking it's value. try "if ($opcost == 0)" instead. the == is for comparison, the single "=" is for setting the variable.
Re: Price updating script ideas
by Zaxo (Archbishop) on Sep 25, 2002 at 15:09 UTC

    use CGI; # or die

    It can take care of both the form writing and the query parsing.

    It also doesn't care whether you use POST or GET. The choice is based on a few secondary properties. GET is always unencrypted and the data shows up in your request log.

    After Compline,
    Zaxo

Re: Price updating script ideas
by Foncé (Scribe) on Sep 30, 2002 at 12:40 UTC
    Eh...yes, I see about the = and == now. That was just a formatting error in my post.

    Working with CGI is new for me, so, does anyone have a good example of a simple form like this with a detailed explination? I've read the Perldoc CGI entry and am still not quite getting it...