Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

cgi popup_menu when radio is selected

by vit (Friar)
on Feb 04, 2008 at 19:27 UTC ( #666060=perlquestion: print w/replies, xml ) Need Help??

vit has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I have a hard time to find a way to show popup_menu() (HTML select) only in case if certain "radio" is checked.
Help me please, if possible.

Replies are listed 'Best First'.
Re: cgi popup_menu when radio is selected
by Popcorn Dave (Abbot) on Feb 04, 2008 at 20:37 UTC
    Is there some reason you don't want to use JavaScript? If you don't use JS, then probably your only other option is AJAX. You might have a look at CGI::Ajax or some of the other Ajax modules on CPAN if that doesn't fit the bill.


    Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

    I would love to change the world, but they won't give me the source code

      Just an opposite. I have nothing against js. If it's not too complicated for you may I ask you at least roughly to show how to use it for this case.
        As ww said, you need to read up on JavaScript, but the basic would be to trigger an event when you check that radio button and use a JavaScript command to open a new window - assuming that's what you're after and proceed from there.

        I think to achieve what you seem to be after that you're better off looking to Ajax as opposed to JavaScript because there are toolkits that I believe that will do that very quickly and then it's just a matter of gluing the code together with the requisite Perl modules. I'd suggest looking at the Dojo toolkit or script.aculo.us toolkit.

        Good luck!


        Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

        I would love to change the world, but they won't give me the source code

        As someone else recently (and wisely) observed,
        "Drop a coin in the COC (Crank Out Code) machine."
        Or, on your own, read up on js and or the modules suggested above.
Re: cgi popup_menu when radio is selected
by bradcathey (Prior) on Feb 05, 2008 at 03:32 UTC

    I'd do this on the client side with a little onclick to show the select tag. I do this a lot and it has nothing to do with Perl.

    <input type="radio" value="1" name="foobar" /> <input type="radio" value="2" name="foobar" onclick="document.getEleme +ntById('menu').style.visibility='visible'" /> <select name="somechoice" id="menu" style="visibility: hidden"> etc.

    You could use display: none and display: block, the difference being display will collapse the space on the page where the menu would go.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      Thanks a lot, it works fine. The only thing is that when I check another radio button select with this id="menue" should disapear.
      If you could give me a hint how to do this I would appreciate.

        Come on! You're not thinking...

        <input type="radio" value="1" name="foobar" onclick="document.getEleme +ntById('menu').style.visibility='hidden'" />
        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: cgi popup_menu when radio is selected
by Anonymous Monk on Feb 04, 2008 at 19:36 UTC
    Hi. You will need to get the value passed in from the request and use it to supply which radio button should be checked. Tell us more and we can help you better.
      I want it to be a dynamic page, so that request is not sent yet. And when XXX is checked
      <input type="radio" name="rad_server_type" value="xml">XXX; <input type="radio" name="rad_server_type" value="org">YYY;
      then this should be shown:
      print $q->popup_menu(-name=>'xml_server',-values=> \@array_of_selecti +ons);
      otherwise not. Something like "on....event" javascript

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2019-06-17 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (76 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!