1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Creating a ComboBox from another ComboBox with database values

Discussion in 'Databases' started by Sql_novice, Feb 20, 2016.

  1. #2
    <fieldset>
    <legend>Team Two:</legend>
    <div>
    <label for="team2">Pick Other Team</label>
    <select id="team2" name="team2" onchange="jsFunction()">
    <option value="Null">Choose One</option>
    <option value="Omaha">Omaha Lancers</option>
    <option value="Farjestan">Farjestan BK U20 - SWE</option>
    <option value="CedarRapids">Cedar Rapids RoughRiders</option>
    <option value="Ilves">Ilves U20 - FIN</option>
    <option value="Lincoln">Lincoln Stars</option>
    <option value="Kalpa">Kalpa U20 - FIN</option>
    <option value="Dubuque">Dubuque Fighting Saints</option>
    <option value="Loko">Loko Yaroslavl U20 - RUS</option>
    <option value="Erie">Erie Otters</option>
    <option value="Mlada">BK Mlada Boleslav - CZE</option>
    <option value="Brandon">Brandon Wheat Kings</option>
    <option value="Sparta">HC Sparta Praha U20 - CZE</option>
    <option value="Rouyn">Rouyn-Norwanda Huskies</option>
    <option value="Claika">Claika Nizhny Novogorod U20 - RUS</option>
    <option value="Shawingan">Shawingan Cataractes</option>
    <option value="HV71">HV71 U20 - SWE</option>
    </select>
    </div>
    </fieldset>

    Calls a JS Function

    <script>

    function jsFunction(){
    var myselect = document.getElementById("team2");
    var ind = myselect.options.selectedIndex;
    <?php
    $abc = $_POST['ind'];

    ?>
    }


    </script>

    $abc = $_POST['ind']; not sure about this line

    code to generate the new combobox

    <fieldset>
    <div>
    <label for="Players"> Players Team Two: </label>
    <?php

    $team=3;

    $dbuser = "draftsag_draft";
    $dbpass = "pearljam0780";
    $dbhost = "localhost";
    $db = "draftsag_sths";
    mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($db);


    $sql2 = "select Name,Age,PosC,PosLW,PosRW,PosD from player WHERE Team='{$abc}' ORDER BY Age";
    $query2 = mysql_query( $sql2 );

    ?>
    <select name="dynamic_data2" onchange="document.getElementById('selected_tex').value=this.options[this.selectedIndex].text">>
    <?php
    $i=0;

    while($get = mysql_fetch_array($query2)) {
    ?>
    <option value="<?=$get['Name'];?>"><?=$get['Name'];?></option>
    <?php
    ++$i;

    }
    if(isset($_POST['search']))
    {

    $makerValue = $_POST['dynamic_data2']; // make value
    SEMrush
    $player = mysql_real_escape_string($_POST['selected_tex']); // get the selected text
    echo "Result:<input type='textarea' value='{$player}'/>";
    }
    ?>
    </select>
    <input type="hidden" name="selected_tex" id="selected_tex" value="" />
    <input type="submit" name="search" value="Add a Player"/>
    </div>
    </fieldset>

    not sure about this code

    The Player combobox is not generating onchange of the orginal combobox - not sure where the error is whether it is the JS to PHP Variable or the above snippet of code
     
    Sql_novice, Feb 20, 2016 IP
    SEMrush