in reply to Re: There's got to be a better way?
in thread There's got to be a better way?

Printing the word CHECKED is exactly what I want to do. I find it to be simpler to have the variables set in advance as opposed to incorporating them into my print statements which would then require an alternative else statement. Also, dealing with them before hand makes reusing the code in another application down the road a whole lot easier.
  • Comment on Re: Re: There's got to be a better way?

Replies are listed 'Best First'.
Re: There's got to be a better way?
by Dominus (Parson) on May 20, 2001 at 19:55 UTC
      ++, good solution. A minor change though, I often find it nicer with a printed text for both situations, i.e:
      print "Box 4: ", $FORM{'h04'} ? 'CHECKED' : 'NOT CHECKED';


      The 15 year old, freshman programmer,
      Stephen Rawls
Re: There's got to be a better way?
by Dominus (Parson) on May 20, 2001 at 20:05 UTC
    Printing the word CHECKED is exactly what I want to do. I find it to be simpler to have the variables set in advance as opposed to incorporating them into my print statements which would then require an alternative else statement.
    If you arrange things correctly, it will all work out right---which was what you were asking for. Change your HTML form to contain HTML code like this:
    <input type=checkbox name='h04' value=' CHECKED '>
    Now when the user checks the checkbox, $FORM{'h04'} will automatically contain the value you want, CHECKED. Then to print out your report, you just say:

    print "Box 4: $FORM{h04}";
    You no longer need the extra variables, because the form variables get the correct values in the first place. No else required.

    --
    Mark Dominus
    Perl Paraphernalia