需要能够添加文本以选择输入字段

时间:2014-02-26 20:41:43

标签: javascript jquery html5 jquery-mobile

我有一个jquery移动表单,根据Project_ID字段选择列表中的选择,获取XML数据以填充一些主要字段

 <script>
    $(document).ready(function() {
    $(function(){
      var Workplans;

    $('#btnxml').click(function() {
    getXML();
    });
    $("#Project_ID").change(function () {
        var selectedIndex = $('#Project_ID option').index($('#Project_ID option:selected')),
            Workplan = $(Workplans[selectedIndex]);

        $('#Area').val(Workplan.find('Area').text());
        $('#Station_Name').val(Workplan.find('Station_Name').text());
        $('#Station_Description').val(Workplan.find('Station_Description').text());
        $('#Station_ID').val(Workplan.find('Station_ID').text());
        $('#Latitude').val(Workplan.find('Latitude').text());
        $('#Longitude').val(Workplan.find('Longitude').text());
        $('#HUC_8_Digit').val(Workplan.find('HUC_8_Digit').text());
        $('#County').val(Workplan.find('County').text());
        $('#Anticipated_Visits').val(Workplan.find('Anticipated_Visits').text());
    });

    function getXML(){

    $.ajax({
        type: "GET",
        url: "http://deq.mt.gov/wqinfo/WQlibrary/SiteVisit/WorkplanReview.xml",
        dataType: "xml",
        success: function (xml) {

        Workplans = $(xml).find('Workplan');

     Workplans.each(function () {
                var Project_ID = $(this).find('Project_ID').text();
                $("#Project_ID").append("<option>" + Project_ID + "</option>");
            });

     $("#Project_ID").trigger('change');

     }
   });
     }
  })
  });

     </script> 
<input type="button" id="btnxml" value="XML" />

      Project ID <select id="Project_ID" name="Project_ID" data-native-menu="true">
          </select>

我的问题是我的用户需要能够将他们自己的值输入到Project_ID字段,因为他们正在处理的项目有时不在选择列表中。 (当然,他们会用手填充所有剩余的字段)

有一种简单的方法吗?

0 个答案:

没有答案