Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Refresh Scrolling List

by sergfuente@coiim.es (Initiate)
on Sep 11, 2012 at 23:28 UTC ( [id://993083]=perlquestion: print w/replies, xml ) Need Help??

sergfuente@coiim.es has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm a new Spanish user and I am now learning Perl and I have one question. How can I refresh a scrolling list from the selected option of other scrolling list using data from a mysql database?"

For example, I have two scrolling lists and one of them is for select the country from a mysql database

The other scrolling list is about the States and it has to be refreshed by what the user has selected in the first scrolling list.

the code for the first scrolling list is easy but how I know the selected country and how I could refresh the data of the second scrolling list

print q(<select tabindex="3" name="country" my $dbh = DBI->connect('DBI:mysql:userxxxx', 'mysqldatabase', '*** +*****') || die "<p>Could not connect to database: $DBI::errstr</p>"; my $sth = $dbh->prepare('SELECT DISTINCT country FROM country ORDE +R BY country'); $sth->execute(); my $result; my $numero=1; print "<option value=\"0\">Please select an option</option>"; while ($result = $sth->fetchrow_array()) { print "<option value=\"$numero\"> $result</option>"; $numero++; } my $datom = param ( 'country' ); print "<p> $datom</p>"; $dbh->disconnect(); print "</select>\n<br>\n";

I believe that the answer must be easy... Thanks

Replies are listed 'Best First'.
Re: Refresh Scrolling List
by NetWallah (Canon) on Sep 11, 2012 at 23:53 UTC
    Bienvenidos!

    The best option would be to use AJAX (CGI::Ajax).

    The easier option would be to make the form SUBMIT when the COUNTRY is selected.
    (You will need javascript 'onClick' or other event to activate this)
    Then, once the COUNTRY is known, populate the STATES.

    Saludos.

                 I hope life isn't a big joke, because I don't get it.
                       -SNL

      Lots of thanks, I am going to investigate CGI::Ajax

      By the way, how is the weather in S. California? It should be great!

      Cheers, Sergio.

Re: Refresh Scrolling List
by Anonymous Monk on Sep 11, 2012 at 23:53 UTC

    ... how I could refresh the data ... I believe that the answer must be easy... Thanks

    What do you mean by "refresh"?

      I want to say with refreshing to updating data to the scrolling list from the mysql database

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://993083]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found