in reply to Re^4: Dynamic Drop down in CGI
in thread Dynamic Drop down in CGI

This site is not a code writing service. Also, this site is chiefly about Perl, not Javascript or HTML. So please don't ask for neither completed code nor Javascript code.

Replies are listed 'Best First'.
Re^6: Dynamic Drop down in CGI
by d0353101 (Novice) on Jun 11, 2009 at 05:27 UTC
    Thanks for all the services (If any) you have provided me !!

    I have not asked you or anyone to write the code for me. I just asked for help. I just asked for an example because I was fed up with trying it out on my own. There is lot of difference between an example and WRITING code. But I think your seniority does not see that.

    Secondly, I am using PERL as programing language. I posted here as I had an assumption that there is code linking between PERL and Java-Script and I was not able to understand that linking. But again your seniority and experience does not see that.

    Please ... Please try to remember the days when you were a Junior and had problems in coding and understanding; and some one must had helped you.

    Please !!

      Everyone is trying to help you. You have to see it from the other side. You have given contradictory requirements (static HTML but dynamic content and no Ajax but with Perl) and no sample code. This is also a messy problemspace with many avenues of attack. Frankly, this is the kind of thing that gets easy only after you've banged your head on your keyboard for months. E.g., it took me twice as long to write up this node as it did to write the jQuery. I can easily see this problem eating up a week of time or more for a new developer. Don't despair though. Pick stuff that's fun and you'll often enjoy the keyboard pattern printed on your forehead.

      Here's demo of an approach that might fit part of what you're after. This is pure HTML and jQuery. It would be easy for someone who knows a JS toolkit and Perl to wire in the server side stuff to make it dynamic (Ajax).

      <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Some auto-populate stuff</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery. +js" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ jQuery(function($){ $("#something").bind("change", function(){ var city = $(this).find(":selected").text(); var index = $(this).val(); var option = $("<option value='" + index + "'>A market in " + city + "</option>"); $("#else").children(":gt(0)").remove().end() .fadeIn("slow") .append(option); }); }); //]]> </script> </head> <body> <select name="something" id="something"> <option value="0">&lt;choose city&gt;</option> <option value="1">Alburquerque</option> <option value="2">Mongoton</option> <option value="3">Zipperville</option> </select> <select name="else" id="else" style="display:none"> <option value="0">&lt;choose market&gt;</option> </select> </body> </html>

      Give that a spin. jQuery is, to me, a lot like Perl. A bit inscrutable at first but then a heavenly match between problems and the way problems are really solved (in human minds).

      Sidebar: Perl and Ajax are generally written titlecased, not in all caps.