Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
This is definitely something that requires Javascript. Here's a self-contained example to get you started. If you need to generate the values in the select boxes dynamically you could either dynamically generate the "osMap" data structure in your CGI, or better yet write a web service that returns just that structure as JSON via a XMLHttpRequest. If you need to do a lot of work like this, I highly recommend investing some time in learning a javascript toolkit like Dojo.
<html> <body> Operating System: <select id="os" onchange="changeOS"> <option>--Choose OS--</option> </select><br/> Flavor:<select id="variant"></select> <script> var osMap = { "Windows":["95","98","NT","ME","2000","XP","Vista"], "Mac":["OS9","OSX(PPC)","OSX(x86)"], "Linux":["RedHat","Ubuntu","Debian","Slackware"] }; var osselect = document.getElementById('os'); var i=1; for (os in osMap){ osselect.options[i++] = new Option(os) } osselect.onchange = function(){ var variant = document.getElementById('variant'); var flavors = osMap[this.options[this.selectedIndex].value]; variant.length = 0; if(flavors){ for(i = 0; i<flavors.length;i++){ variant.options[i] = new Option(flavors[i]); } } } </script> </body> </html>

In reply to Re: CGI.pm and dynamic dropdown menus by thunders
in thread CGI.pm and dynamic dropdown menus by vxp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (5)
    As of 2014-12-27 19:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

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





      Results (177 votes), past polls