Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Dynamic Dropdowns

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #149327
    heinz
    Participant

    Hi I have used the script “Dynamic Dropdown” and I find it very good. But I would like to have the second dropdown showing the selected item. That means I mus send a second argument to the getter.php, but I don’t know how to do it. Here is the code of the getter.php-file:

    ` $choice = mysql_real_escape_string($_GET[‘choice’]); $g_id = mysql_real_escape_string($_GET[‘g_id’]);

    $query = "SELECT * FROM graeber WHERE f_id='$choice'"; $result = mysql_query($query);
    
    while ($row = mysql_fetch_array($result))
    {
        if ($row['g_id'] == $g_id)
        {
            echo "<option value=" . $row['g_id'] .  " selected=\"selected\">" . $row{'grabnummer'} . "</option>";
        }
        else
        {
            echo "<option value=" . $row['g_id'] . ">" . $row{'grabnummer'} . "</option>";
        }
    }`
    

    This is the argument that also should be submitted:

    $g_id

    and this is the jquery-code:

    $("#f_id").change(function() {
    $("#g_id").load("get_select_input.php?choice=" + $("#f_id").val());
    

    });

    Does anyone have an idea how to manage this? Thank you in advance for you help. Heinz

    #149400
    heinz
    Participant

    Hello all
    I have found a solution for my problem. I send the parameters via POST and in getter.php I fetch these params as follows

    `$choice = mysql_real_escape_string($_POST[‘choice’]);

    $g_id = mysql_real_escape_string($_POST[‘g_id’])
    `
    and the jquery-script goes like this:

    $("#f_id").change(function() {
    $("#g_id").load("get_select_input.php", {
    'choice' : $("#f_id").val(),
    'g_id' : <?php echo $g_id;?>
    });

    Regards,
    Heinz

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.