How to get variable information from radio buttons in a form
Here's the thing, I have a form that has radio buttons in it (only one choice). Obviously these radio buttons, to work properly, have the same name but different values.
How do I get the variable to look like:
$FORM{'namevalue'}
instead of
$FORM{'name'}
??
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
fairhousing posted this at 08:28 — 24th March 2000.
They have: 1,587 posts
Joined: Mar 1999
u just make the name in the form match the $FORM{'name'} in the script.
ah, i hope that helps, i'm a little confused by the question.
Suzanne posted this at 08:36 — 24th March 2000.
She has: 5,507 posts
Joined: Feb 2000
Thanks, Fairhousing, about a minute after I posted I realized I had my thinking wrong. What I need to do is test if $FORM{'name'} = "specific value"... whereas most of the other variables I just need to test if they exist, and if so, print the value.
Is that clearer? Can ya tell I've been learning Perl for all of 2.5 weeks? lol!
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
Suzanne posted this at 09:01 — 24th March 2000.
She has: 5,507 posts
Joined: Feb 2000
This was my solution (in case anyone else is terribly curious:
# first, fix the variables
if ($FORM{'blah'} eq 'something') {$something = 'something';}
if ($FORM{'blah'} eq 'thisthing') {$thisthing = 'thisthing';}
if ($FORM{'blah'} eq 'thatotherthing') {$thatotherthing = 'thatotherthing';}
# then use the variable to print the information
if ($something) {$thisone = $something};
if ($thisthing) {$thisone = $thisthing};
if ($thatotherthing) {$thisone = $thatotherthing};
# this is used to print $thisone, no matter whether
# we are dealing with something, thisthing or thatotherthing... but that's another piece
# then later, I use the same variable to add details to the
# atextfile.txt for the sending in an e-mail
if ($something)
{
open (SOMETHING, "something.txt");
@something = <SOMETHING>;
printf SOMEFILE @something;
close SOMETHING;
}
And there we go! Whoo hoo!!!
It was the missing piece, yay!
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
fairhousing posted this at 19:08 — 24th March 2000.
They have: 1,587 posts
Joined: Mar 1999
i think u could shorten that code up a little. put the code here and some of us might be able to help. i'm pretty new to perl/cgi myself, watch out!
------------------
CLICK 4 some tested resources for making money $, hosting, and web promotions.
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
Suzanne posted this at 21:46 — 24th March 2000.
She has: 5,507 posts
Joined: Feb 2000
Oh I am sure I can get the code a lot trimmer, but I am not going to post it as the entire script is well over 450 lines not including the included files.
Suffice it to say that the variables in question indicate which extra file (text) gets printed to an order file and sent to the customer.
You can see it at work at www.zerocattle.com/zerocattle_order.html (calculating the total is not a committment -- you place the order on the next page) but to see the full effect, you would have to order something. As it is, when you calculate an order, it prints the Payment method on the order summary on the next page. I am adding a snip so that if you do not choose a payment method, you cannot proceed.
Clear as mud, eh?
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.