简体   繁体   中英

show the selected drop down values to the another table

I am Have html table inside each td i have dropdown see below image how it looks like

在此处输入图片说明

if i select 1201 in dropdown of second td also i want to change the value of to other dropdown with the same id,if the id is not matched it will not change

<td style="width:141px" id="CPH_GridView1_route'.$rows['net_id'].'" >
    <select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" >
            <option value="-1">Choose..</option>';
            <option value="-1">1201</option>';
            <option value="-1">1101</option>';
    </select>
</td>

ajax

<script>
    $(document).ready(function(){
        $('.edit1').on('change', function(){
            $.ajax({    type: "POST",
                url:"xxxxx/routestatusupdate.php",
                data:"value="+$(this).val()+"&rowid="+arr[2]+"&field="+arr[1]+"&clientid="+clientid+"&account_id="+account_id,
                success: function(res){
                    data = jQuery.parseJSON(res); //added line
                    alert('Saved Successfully!');
                    $('#CPH_GridView1_route').empty();
                    $('#CPH_GridView1_route').append(data.routeupdate);
                    $('.ajax').html($(this).val());
                    $('.ajax').removeClass('ajax');
                }
            });
        });
    });        
</script>
<select name="mySelect" id="mySelect" class="edit1 route '.$rows["net_id"].'" onChange="foo()">
        <option value="-1">Choose..</option>';
        <option value="-1">1201</option>';
        <option value="-1">1101</option>';
</select>
<select name="second" id="mySelect" >
        <option value="-1">Choose..</option>';
        <option value="-1">1</option>';
        <option value="-1">2</option>';
</select>


 <script>
function foo(){
alert("cahnge");
document.getElementById("div1').innerHTML="<select name="second" id="mySelect" >
        <option value="-1">Choose..</option>';
        <option value="-1">1</option>';
        <option value="-1">2</option>';
</select>";

}
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM