SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how can i insert drop down option values into the select

    Hi i have this form which the drop down options value is based on database query, i want to when onchange to add the drop down option value into the select value but i cant seem to be able to grab the drop down values, the drop down variable is $area_name i want to add from the drop down option to
    here
    PHP Code:
    echo " <select name=\"aid\" size=\"1\" onchange=\"jwplayer().load({file:'http://www.onfilm.biz/streaming/home/area_films/ ".$area_name.".flv'});jwplayer().play(true);\" style=\"width:160px\"> 
    PHP Code:
            <form id="area_films" action="<?php echo $_SERVER['PHP_SELF']; ?>"  method="post" name="area_films">
                        <?php
                        
    //get the DB connection variables
                        
    include("includes/config.php");
                        
    //connect to DB
                        
    $connectionat = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT.");
                        
    $dbcat = @mysql_select_db($db_name$connectionat) or die("Couldn't select DATABASE.");
                        
    //SELECT or FIND the same PASSWORD
                        
    $queryat="SELECT * FROM films_area WHERE (area_type = 'town' OR area_type = 'village' OR area_type = 'city') ORDER BY area_town ASC";
                        
    $resultat mysql_query($queryat) or die("Couldn't execute QUERY - FIND Client TVs");
                        
    echo 
    " <select name=\"aid\" size=\"1\" onchange=\"jwplayer().load({file:'http://www.onfilm.biz/streaming/home/area_films/ ".$area_name.".flv'});jwplayer().play(true);\" style=\"width:160px\"> 
                    <option value=\"none\">...location films...</option>"
    ;
                            while (
    $rowat mysql_fetch_array($resultat))
                                {
                                    
    $area_id=$rowat['area_id'];
                                    
    $area_name=$rowat['area_town'];
                                    if(
    $rowat['area_country'] == 'France')
                                {
                                     
    $area_name =  $area_name."(F)";
                                } 
                                    print(
    "<option value='$area_id'>$area_name</option>");
                                }
                                    
    mysql_close($connectionat);
                            
    ?>
                </select>
                    <input style="width:70px;" type="submit" name="view" value="SEARCH" />
            </form>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    So if I understand correctly, you want to change the value in the <select> tag when the user chooses another option from the drop down?
    You can't do that with PHP. You'll have to use Javascript to get the selected value, and put it where you want to use it.

  3. #3
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    It looks like you want to play the selected video file (.flv).

    If that is the case, just call a function in the <select>'s onchange event handler to which you pass the selected option's value (this.value). The event handler function then runs the code to play the selected video.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •