P
Paanwa
I am trying to write more automated code - either I am a lazy typist or am
just trying to get more with it!
I have a hash I define; I have a form with textboxes for each hash elements.
When the form is submitted the user gets a chance to review their data prior
to finalizing (writing to file).
The form is running from the same piece of code; I would like it to use the
hash values if it is the first time through (the hidden form object named
cycle is set to 0), but use the submitted (either changed or left alone)
data for the second time through - which is the 'review' part mentioned
above (cycle is set to 1).
I really don't want to set my form values manually:
(summary, not actual code)
if (param('cycle') = 0)
{
set Address1 = $hash{$key}{Address1};
}
else
{
set Address1 = param('Address1');
}
I would like to loop through the names of the hash elements like this:
(summary, not actual code)
foreach element_name (keys %hash)
{
if (param('cycle') = 0)
{
set form element_name value = $hash{$key}{element_name};
}
else
{
set form element_name value = param('element_name');
}
}
Note: I name each form object after the corresponding hash name.
So, can this be done?
just trying to get more with it!
I have a hash I define; I have a form with textboxes for each hash elements.
When the form is submitted the user gets a chance to review their data prior
to finalizing (writing to file).
The form is running from the same piece of code; I would like it to use the
hash values if it is the first time through (the hidden form object named
cycle is set to 0), but use the submitted (either changed or left alone)
data for the second time through - which is the 'review' part mentioned
above (cycle is set to 1).
I really don't want to set my form values manually:
(summary, not actual code)
if (param('cycle') = 0)
{
set Address1 = $hash{$key}{Address1};
}
else
{
set Address1 = param('Address1');
}
I would like to loop through the names of the hash elements like this:
(summary, not actual code)
foreach element_name (keys %hash)
{
if (param('cycle') = 0)
{
set form element_name value = $hash{$key}{element_name};
}
else
{
set form element_name value = param('element_name');
}
}
Note: I name each form object after the corresponding hash name.
So, can this be done?