Re: Counters in variable names.
From: dw (me_at_verizon.invalid)
Date: 03/22/04
- Next message: Joe Smith: "Re: diff"
- Previous message: Gary: "Counters in variable names."
- In reply to: Gary: "Counters in variable names."
- Next in thread: nobull_at_mail.com: "Re: Counters in variable names."
- Reply: nobull_at_mail.com: "Re: Counters in variable names."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 22 Mar 2004 01:48:22 GMT
"Gary" <reachus@netlink.info> wrote in message
news:W8r7c.12945$1e1.1473@lakeread06...
>My HTML reads a file and writes out field names to include a counter so I
have fields like
>
><input type=text name=surname$counter><input type=checkbox
name=update$counter>
>
>When they click update these fields are sent to the update program for
update.
>
>If the person changes this field they will also tick the change checkbox
and I want to be able to loop through all the fields and update them as
below
>
>UPDATE Program
>for($counter=0 ; $counter < $totalrecords ; $counter++)
>{
>if ($update$counter)
>{ blah blah}
>
>The problem is that Perl does not seem to like me adding a variable
($counter) to a variable name ($update) and the only other way would be long
winded like
>if ($update1) {Blah Blah}
>if ($update2) {Blah Blah}
>
>How can I get a variable to be part of anothers variable name.
>
>G
how about using something like:
${"update$counter"}
however, I assume that you are using CGI.pm and can use something like:
$q->param("update$counter")
or stuff the values into a hash:
$update{$counter} = $q->param("update$counter")
- Next message: Joe Smith: "Re: diff"
- Previous message: Gary: "Counters in variable names."
- In reply to: Gary: "Counters in variable names."
- Next in thread: nobull_at_mail.com: "Re: Counters in variable names."
- Reply: nobull_at_mail.com: "Re: Counters in variable names."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]