Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: passing an array to a checkbox_group

by amulcahy (Acolyte)
on Oct 11, 2001 at 14:57 UTC ( #118187=note: print w/ replies, xml ) Need Help??


in reply to Re: passing an array to a checkbox_group
in thread passing an array to a checkbox_group

That worked, thanks. I have a follow-up question:
In the 'multipart_form' I set a param 'TblMenu' to $STable, but when I call it from another Perl script it doesn't recognise it.

$STable = 'tab001'; print $query->start_multipart_form("POST","printFields"); print $query->checkbox_group(-name=>'FieldNames', -value=>[ @array ]); $query->param( -name=>'TblMenu', -value=>$STable); print $query->submit('doWhat','Print Fields'); print $query->end_form;
Calling Code:
$SFields = join(", ",$query->param('FieldNames')); $STab = $query->param('TblMenu');
$SFields returns the selected checkboxes
$STab returns nothing.
I feel like there should be something like
$STab = $query->param('FieldNames.TblMenu');
but I don't know what it is?

AM


Comment on Re: Re: passing an array to a checkbox_group
Select or Download Code
Re: Re: Re: passing an array to a checkbox_group
by khippy (Scribe) on Oct 11, 2001 at 15:03 UTC
    Is it a tip to include a print statement at line 5 ?
    --

    there are no silly questions

    killerhippy
      I presume you mean this....
      print $query->param( -name=>'TblMenu', -value=>$STable);
      I tried that but it did not work?
        Ok, I (now really having read the code) presume, that you
        simply want to set the CGI-variable, don't you?
        In this case, perldoc CGI tells:

        the param() routine is used to set a CGI parameter
        [..]
        $q->param(-name=>'veggie',-value=>'tomato');


        where $q is determined by the previously stated
        $q = new CGI; # create new CGI object

        So, your statement seems perfectly right. The only clue
        is, that you "call it from another Perl script". In this
        case you have to export/import variables, haven't you?
        If so, wait for another PerlMonk to answer this, because
        I am not experienced with exchanging variables between
        perlscipts.
        --

        there are no silly questions

        killerhippy
Re: Re: Re: passing an array to a checkbox_group
by guidomortonski (Sexton) on Oct 11, 2001 at 16:43 UTC
    If I understand what you are asking, you seem to be wanting to set a variable in one script that outputs some html, and then access that variable's value the next time the form is submitted?

    If that's the case you need to be writing a hidden field into your first script's output that has the name and value you want to access in your second script. CGI.pm probably has a method for doing this.

    Guy

Re: Re: Re: passing an array to a checkbox_group
by thatguy (Parson) on Oct 11, 2001 at 16:45 UTC
    my tests seem to work ok, but I am unclear on how you are calling this from another script. do you mean as the action or some other means?

    Update: seems to work when I added this after line 7 in the first script.

    print $query->hidden('TblMenu');

    is this what you were wanting?

      OK - 'main' contains the form which calls 'second'

      main:
      use CGI; $query = new CGI; print $query->start_multipart_form("POST","second"); print $query->checkbox_group(-name=>'FieldNames', -value=>[ @array ]); $query->param( -name=>'Tbl1', -value=>'tabname'; print $query->submit('doWhat','Print Fields'); print $query->end_form;
      second:
      use CGI; $query = new CGI; $SFields = join(", ",$query->param('FieldNames')); $STab = $query->param('Tbl1');
      The result is:
      $SFields = Date, Forename, Middle, School
      $STab = Nothing?????

      AM
      that did it - thanks for your help, it was driving me batty.
Re: Re: Re: passing an array to a checkbox_group
by ralphie (Friar) on Oct 12, 2001 at 01:18 UTC
    you have to pull the values from the checkbox with a param .. e.g.,
    @fieldnames=$query->param('FieldNames')
    and the resultant array is less tractable to splits and other parsing operations, so be prepared to use a substr() to separate out what you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://118187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-12-22 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (119 votes), past polls