Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:50:02+00:00 2026-06-08T08:50:02+00:00

I have got it working up to the third select list. But there are

  • 0

I have got it working up to the third select list. But there are 4.

country, source, target and subject.

I am able to select up to the target select list alright, but I can’t make it to the final one, the subject. This is because I don’t know how to complete the missing code for that one.

Here is the script and further below will be the processing one. So it is the ‘subject’ select list that needs to move accordingly to its next to the left:

jQuery(document).ready(function () {
    jQuery("#sel_pais").change(function () {
        //
        var datatosend = 'pais_id=' + jQuery(this).val();
        jQuery.ajax({
            type:'GET',
            url:'includes/getchilds2.php',
            data:datatosend,
            dataType:"json",
            success:function (data) {
                jQuery('#sel_source').find('option').remove().end();
                jQuery('#sel_target').find('option').remove().end();
                jQuery.each(data, function (index, val) {
                    var newopt = '<option value="' + val.key + '">' + val.title + '</option>';
                    jQuery('#sel_source').append(newopt);
                });
                jQuery('#sel_target').append('<option value="-1">Select</option>');

            }

        });
    });
    //////////////////////
    jQuery("#sel_source").change(function () {
        //
        var datatosend = 'id_from=' + jQuery(this).val();
        jQuery.ajax({
            type:'GET',
            url:'includes/getchilds2.php',
            data:datatosend,
            dataType:"json",
            success:function (data) {
                jQuery('#sel_target').find('option').remove().end();
                jQuery.each(data, function (index, val) {
                    var newopt = '<option value="' + val.key + '">' + val.title + '</option>';
                    jQuery('#sel_target').append(newopt);
                });
            }

        });
    });


});

And here is the processing one:

<?php
$con = mysql_connect("localhost", "root", "");
if (!$con) {
    die('Could not connect: ' . mysql_error());
}

mysql_select_db("traducteurs", $con);
//
if (isset($_GET['pais_id'])) {
    $curid = $_GET['pais_id'];
    //  
    $result = mysql_query("SELECT * FROM tabla_from where pais_id=" . $curid);
    if (mysql_num_rows($result) > 0) {
        $op = '[';
        $op .= '{"title":"Select","key":"-1"},';
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $op .= '{';
            $op .= '"title":"' . $row['from_name'] . '", "key":"' . $row['id_from'] . '"';
            $op .= '},';
        }
        $op = substr($op, 0, -1);
        $op .= ']';
        echo $op;
    }
    else {
        echo '[{"title":"Select","key":"-1"}]';
    }
}
/////////////////////
if (isset($_GET['id_from'])) {
    $curid = $_GET['id_from'];
    //  
    $result = mysql_query("SELECT * FROM tabla_into where id_from=" . $curid);
    if (mysql_num_rows($result) > 0) {
        $op = '[';
        $op .= '{"title":"Select","key":"-1"},';
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $op .= '{';
            $op .= '"title":"' . $row['into_language'] . '", "key":"' . $row['id_into'] . '"';
            $op .= '},';
        }
        $op = substr($op, 0, -1);
        $op .= ']';
        echo $op;
    }
    else {
        echo '[{"title":"Select","key":"-1"}]';
    }
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:50:03+00:00Added an answer on June 8, 2026 at 8:50 am

    I am using this code to show interdependent list

    <select id="sel_pais" name="sel_pais">
    <option value="pais_id">values goes here</option>
    </select>
    
    <select id="sel_source" name="sel_source">
    <option value="">Select</option>
    </select>
    
    <select id="sel_target" name="sel_target">
    <option value="">select</option>
    </select>
    
    <select id="sel_subject" name="sel_subject">
    <option value="">select</option>
    </select>
    //jquery code for source list
    $('#sel_pais').change(function() {
      if ($(this).val()!='') {
        $("#sel_source").load("include/getchild2.php",{pais_id: $(this).val()});
      }
    });
    //code on change of sel_source
    $('#sel_source').change(function() {
      if ($(this).val()!='') {
        $("#sel_target").load("include/getchild2.php",{id_from: $(this).val()});
      }
    });
    
    $('#sel_target').change(function() {
      if ($(this).val()!='') {
        $("#sel_subject").load("include/getchild2.php",{id_target: $(this).val()});
      }
    });
    

    php sample code you can change.. repeat the below code for others.

        if(isset($_REQUEST['pais_id']) && !empty($_REQUEST['pais_id'])) {
        $result = mysql_query("select * from table where id='".$_REQUEST['pais_id']."' "));
        if(mysql_num_rows($result) > 0) {
            echo '<option value="">Select</option>';
            while($row = mysql_fetch_assoc($result)) {              
                    echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
            }
        } else {
            echo '<option value="">Select</option>';
        }
    } 
    

    hope this will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the project I'm working on I have got a list List<Item> with objects
I am certain I have got this working in the past, but it doesn't
I have got tinyMCE working in the django admin, but all the popups are
I am working with IronPython and have got it working somehow. Though, there seems
I'm following the Django-CMS introductory tutorial and have got everything working up to the
I have got one weird issue. I am working on an asp .net mvc
I'm working on a vbscript program and I have got and Expected Statement Error.
Presently Iam working in finding disparity of stereo pair. I have got a situation
I have spent last 3 days until I got gps working on android using
I installed TeamCity and got it working against my project. However, I have since

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.