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
    <legend>Team Two:</legend>
    <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>

    Calls a JS Function


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



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

    code to generate the new combobox

    <label for="Players"> Players Team Two: </label>


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

    $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">>

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


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

    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