List:General Discussion« Previous MessageNext Message »
From:Christopher R. Jones Date:May 8 2000 1:58pm
Subject:Re: Drop Down Menu with defined Data:
View as plain text  
For one site, I use Perl CGI to create the javascript pulldowns.  It makes 
for a fairly long perl script but it works very well.
You cannot do what you are trying below.  CGI sends the results from the 
entire script back to the client browser.  In your case, the my $choice = 
$query->param("COLLEGE"); is undefined until after the client has made the 
selection so you would need a series of  Perl scripts - the first one to 
present the list of Colleges, and the second one to present the list of 
department based on the first pages selection, and so one.  Obviously, one 
perl script that creates the Javascript arrays for the dynamic pulldowns is 
you best option.


>Ben,
>Thanks for the link-
>
>I've already got something like that - I guess I can make the query to Mysql
>before the Javascript.  Looks like they ran into the same problem I did and
>they had to insert the "---------------" so that the displayed data 
>could  read
>properly.
>
>But couldn't I pull the selected data with a param statement?
>Check out the example below and let me know if this will work.
>
>  print "Please Select your College";
>my $sth = $dbh->prepare("select college from list")
>  $sth->execute;
>my @arr=();
>while (@arr = $sth->fetchrow_array())
>  {
>($college)=@arr;
>  $college = $college;
>  print $query->popup_menu (-name=>'COLLEGE',
>                           -"values"=>['$college',
>
>  ],
>  -default=>$defaultcollege);
>  }
>  $sth->finish();
>## now grab the choice from the drop down menu?
>my $choice = $query->param("COLLEGE");
>## would I need to add my $query= new CGI;
>##and then I could plug $choice into the next select statement:
>
>  ## second drop down menu
>print "<BR>";
>  print "Please Select the Department</td><td>";
>  my $sth = $dbh->prepare("select dept from list
>  where college="$choice" ")
>  $sth->execute;
>  my @arr=();
>  while (@arr = $sth->fetchrow_array())
>  {
>  ($dept)=@arr;
>  $dept = $dept;
>  print $query->popup_menu (-name=>'DEPT',
>                           -"values"=>['$dept',
>
>  ],
>  -default=>$defaultdept);
>  }
>
>
>
>benjamin-weiss wrote:
>
> > Doug,
> >
> > I ran across a site the other day that does something like this.  I looked
> > at the source, and they're using javascript, but a good part of that script
> > can be generated dynamically from MySQL.
> >
> > The link is:
> >
> > http://www.csd.toshiba.com/cgi-bin/tais/home.jsp
> >
> > Then choose the Technical Support link at the top right, then the Tech
> > Support Center in the middle.  You'll see three list boxes.  Have fun!
> >
> > Ben
> > ----------------------------
> > BENJAMIN J. WEISS
> > 2LT, SC, OKARNG
> > 45th Infantry Brigade (SEP)
> > Signal Platoon Leader
> >
>
>
>--
>---------------------------------------------------------------------
>Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>posting. To request this thread, e-mail mysql-thread36527@stripped
>
>To unsubscribe, send a message to:
>     <mysql-unsubscribe-##L=##H@stripped>

Christopher R. Jones, P.Eng.
14 Oneida Avenue
Toronto, Ontario M5J 2E3
Tel. 416 203-7465
Fax. 416 203-3044
Email cj@stripped


Thread
Drop Down Menu with defined Data:Douglas Brantz8 May
  • Re: Drop Down Menu with defined Data:Douglas Brantz8 May
    • RE: Drop Down Menu with defined Data:benjamin-weiss8 May
      • Re: Drop Down Menu with defined Data:Douglas Brantz8 May
        • Re: Drop Down Menu with defined Data:Christopher R. Jones8 May
        • RE: Drop Down Menu with defined Data:benjamin-weiss8 May