Hi Rob...

Thanks man...Like babbling ,I have coded for my requirement........Please
have a glance on the portion of my code .....
Now almost I got the solution...trying to optimize it...........

*Note:
*The value of $ country_code is obtained by the following line *
my $country_code = $cgi->param('COUNTRY_CODE');
*

<TR HEIGHT="25">
<TD WIDTH="140" ALIGN="RIGHT">
<STRONG>Country: </STRONG>
</TD>
<TD WIDTH="650" ALIGN="LEFT">

<select id="country" name ="COUNTRY_CODE"

OnChange="Javascript:document.location.href='plant_catalog_new_changes.cgi?REVIEW_REGION='+document.forms[0].REVIEW_REGION.value+'&amp;COUNTRY_CODE='+document.forms[0].COUNTRY_CODE.value;"
>
<option value="">Select</option>

 \n ~;

if($review_region eq 'Europe')
{
my %Europe = (BE => 'Belgium',
   DK => "Denmark",
   FR =>"France",
   DE => "Germany",
   IO => "Great Britain",
   HU => "Hungary",
   PT => "Portugal",
   RU => "Russia",
   ES => "spain",
   SE => "Sweden",
   TR => "Turkey");

my $item="$country_code";
while (my($key,$value) = each( %Europe))
{
my $country_code=$key;
my $country=$value;
 if ($country_code eq $item) {
        $selected_switch = "selected";
}
else {
$selected_switch = "";
  }
   print qq~  <option value = "$country_code"
$selected_switch>$country</option> \n~;
}
print qq~ </select> \n
\n~;
}

elsif($review_region eq 'North America')
{
my %North = (US => "U.S.",
   CA => "Canada",
   MX => "Mexico");
my $item="$country_code";
while (my($key,$value) = each( %North))
{
my $country_code=$key;
my $country=$value;
 if ($country_code eq $item) {
        $selected_switch = "selected";
}
else {
$selected_switch = "";
   }
   print qq~  <option value = "$country_code"
$selected_switch>$country</option> \n~;
}
print qq~ </select> \n
\n~;
}

elsif($review_region eq 'South America')
{
my %South = ( AR => "Argentina",
   BR => "Brazil",
   VE => "Venezuela");
my $item="$country_code";
while (my($key,$value) = each( %South))
{
my $country_code=$key;
my $country=$value;
 if ($country_code eq $item) {
        $selected_switch = "selected";
}
else {

$selected_switch = "";
   }

   print qq~  <option value = "$country_code"
$selected_switch>$country</option> \n~;
}
print qq~ </select> \n

\n~;
}

else
{
my %Asia = (AU => "Australia",
   CN => "China",
   IN => "India",
   MY => "Malaysia",
   NZ => "NewZealand",
   PH => "Philippines",
   ZA => "South Africa",
   TW => "Taiwan",
   VN => "Vietnam");

my $item="$country_code";
while (my($key,$value) = each( %Asia))
{
my $country_code=$key;
my $country=$value;
 if ($country_code eq $item) {
        $selected_switch = "selected";
}
else {
$selected_switch = "";
   }
   print qq~  <option value = "$country_code"
$selected_switch>$country</option> \n~;
}
print qq~ </select> \n
\n~;
}
print qq ~

</TD>
</TR>

Thanks and Regards,
Ela...


On Mon, Jul 14, 2008 at 10:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote:

>
> elavazhagan perl wrote:
> >
> > I have two combo boxes in which the first one is used for choosing the
> > Regions and the second one is for the corresponding countries.
> > I would like to do this with Perl and html  without  importation any
> modules
> > and eventhough it is better by Javascript.
> >
> > I am getting the pull down menu values through cgi Param functions.
> > Now when the user chooses the region and the country,the values are
> assigned
> > to the $review_region and the $country_code res.
> >
> > While I am trying to hard code the display by the following way.. the
> > following country overrides the previous one.
> >
> > my requirement is when the user choose the region,only the corresponding
> > countries  should be displayed.
> > Please pardon me the clarification is not sufficient and let me know to
> add
> > more...
>
> If you want the options in the countries list to change according to the
> value
> selected from the regions list then you must write in JavaScript. A Perl
> CGI
> program will only see the option chosen once the submit button is pressed,
> whereas you can write a client-side JavaScript event handler to alter the
> contents of one list whenever the value of another changes.
>
> To write in Perl CGI you would have to have a form with just a region list.
> Selecting from that list and submitting the form would bring up a second
> form
> with the countries from that region.
>
> Please describe in detail what behaviour you want from your form.
>
> Rob
>

Reply via email to