in reply to Re: How do I display a textbox only if a certain value is selected from a dropdown list
in thread How do I display a textbox only if a certain value is selected from a dropdown list

I'm using the perl CGI module, I'm not using javascript anywhere.
  • Comment on Re^2: How do I display a textbox only if a certain value is selected from a dropdown list

Replies are listed 'Best First'.
Re^3: How do I display a textbox only if a certain value is selected from a dropdown list
by Utilitarian (Vicar) on Aug 19, 2009 at 16:08 UTC
    hi,

    I think what lostjimmy meant is that the solution is a javascript one, ie. you're going to have to use javascript. A quick and dirty example of how to go about it.

    <html> <head> <script language="javascript"> function getOther(selector,inputID){ var selector=document.getElementById(selector); var inputID=document.getElementById(inputID); if (selector[selector.selectedIndex].value=="Other"){ inputID.style.display= "block"; }else{ inputID.style.display="none"; } } </script> </head> <body> <select id="OSSelection" name = "OS" onchange="getOther('OSSelection', +'OtherOS')"> <option value = "Unix">Unix</option> <option value = "Multics">Multics</option> <option value = "VMS">VMS</option> <option value = "OSX">OSX</option> <option value = "Other">Other</option> </select> <input type="text" name="OtherOS" id="OtherOS" style="display: none;"> </body> </html>
    You could of course have a javascript library on your server which was included in each page and provided functions such as that above throughout the site.
    use CGI qw(:standard); ... print start_html({ "-title"=>"A JS Demo", "-script" => { "-src" =>"/scripts/functions.js" } } )
      Yeah, you're right. I was a bit hasty in my response and should have given more of a complete answer. And for that I apologize, wishartz; I should have been more helpful.