1

我有两个下拉菜单。在一个下拉列表中选择一个值时,XML 文件中的相应值应该出现在下拉列表 2 中。相应的值在下拉 2 中完美出现,但每次我在下拉 1 中选择值时,它的宽度都会减小。我没有得到真正的问题所在。这个你能帮我吗。脚本代码:

var XML_PATH = "web/jsp/test.xml";
$(function getDropThreeDetails() {
$('#ddl3').empty();
$.ajax({
        type: "GET",
        url: XML_PATH,
        dataType: "xml",
        success: function(xml)
        {
            var selectedVal = $('#ddl2').val();
            $(xml).find(selectedVal).find('values').each(function(i)  {
                var ou2 = $(this).text();
                $('#ddl3').append("<option id='"+ ou2 +"'>"+ou2+"</option>");
            });

    }
  });
}); 

HTML 代码:

    <td class="text1" align="left" colSpan="1"><b><font
        color="#5B5B5B" face="Arial">Service Request Category</font></b></td>
    <td><select id="ddl2"
        onchange="getDropThreeDetails(this,'ddl3')" style="width: 100%"
        Class="textbox">
    </select></td>
</tr>

<tr>
    <td class="text1" align="left" colSpan="1"><b><font
        color="#5B5B5B" face="Arial">Service Request Type</font></b></td>
    <td><select id="ddl3" style="width: 100%" Class="textbox">
    </select></td>
</tr>

XML 文件代码:

<Statements>
    <values>Request for Final Interest certificate</values>
    <values>Request for Provisional Interest certificate</values>
    <values>Request for Amortization/Repayment Schedule for ROI/Balance tnure and o/s loan amt</values>
    <values>Statement of account</values>
    <values>Query on Statement/Certificates/Amortization chart</values>
</Statements>

<Disbursement>  
    <values>Part Payment Enquiry</values>
    <values>Part Payment Request</values>
    <values>Query on Part Payment request made</values>
    <values>Part Payment not Adjusted Properly</values> 
</Disbursement>

4

1 回答 1

0

您可以将选择框设置为固定宽度。像这样的东西:

<select id="ddl3" style="width: 200px">

但最好使用 CSS 来完成。

select.big {
    width: 200px;
}
<select id="ddl3" class="big">
于 2013-01-31T07:57:04.193 回答