Re: [PHPLIB] unable to use a variable in form element From: Florian Gnägi (gnaegi <email protected>)
Date: 12/09/99

$week_num = $date->week_num;

$this->form_data->add_element(array( "type"=> "hidden",
                                     "name"=> "week_ending",
                                    "value"=> $week_num);

will solve your problem...

have fun

-florian

On Thu, 9 Dec 1999, Bruce Snyder wrote:

> I am unsuccessful in setting a variable to the value of a hidden form
> element. Here is my code:
>
> ------------------------------------------
> <?php
>
> include( '/usr/www/Date.inc'); // for week of year calc
> $date = new Date;
>
> class StatusForm extends tpl_form
> {
>
> var $classname = "StatusForm";
> var $form_data;
>
> function setup_fields()
> {
> $this->form_data->add_element(array( "type"=> "hidden",
> "name"=> "week_ending",
> "value"=>
> "$date->week_num"));
> ...
> } // end class StatusForm
> ------------------------------------------
>
> Notice the value of the hidden field named week_ending should be the
> variable $date->week_num. I've tried it with double quotes, with single
> quotes, with no quotes, etc. and it will not report the contents of
> $date->week_num. When the hidden field is output its value is empty.
>
> I wrote a little test file and $date->week_num is being calculated
> properly.
>
> Thanks,
> Bruce Snyder
> -
> PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
> To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
> the body, not the subject, of your message.
>

-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.