Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
动作(xml){var$xml=$(xml);var计划=$xml.find('plan');…})现在它可以工作了。谢谢,我可以调用PHP页面并将planNumber传递给它,然后默认选择这些值吗?例如test.php?plannumber=773和值表_Php_Jquery_Xml_Parsing - Fatal编程技术网

动作(xml){var$xml=$(xml);var计划=$xml.find('plan');…})现在它可以工作了。谢谢,我可以调用PHP页面并将planNumber传递给它,然后默认选择这些值吗?例如test.php?plannumber=773和值表

动作(xml){var$xml=$(xml);var计划=$xml.find('plan');…})现在它可以工作了。谢谢,我可以调用PHP页面并将planNumber传递给它,然后默认选择这些值吗?例如test.php?plannumber=773和值表,php,jquery,xml,parsing,Php,Jquery,Xml,Parsing,动作(xml){var$xml=$(xml);var计划=$xml.find('plan');…})现在它可以工作了。谢谢,我可以调用PHP页面并将planNumber传递给它,然后默认选择这些值吗?例如test.php?plannumber=773和值表单MISSOURI-NUT默认填充表单?感谢使用此表单,Rohan的代码运行良好。感谢使用此表单,Rohan的代码运行良好。 <script src="http://code.jquery.com/jquery-latest.min.js


动作(xml){var$xml=$(xml);var计划=$xml.find('plan');…})现在它可以工作了。谢谢,我可以调用PHP页面并将planNumber传递给它,然后默认选择这些值吗?例如
test.php?plannumber=773
和值表单
MISSOURI-NUT
默认填充表单?感谢使用此表单,Rohan的代码运行良好。感谢使用此表单,Rohan的代码运行良好。
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function() {

    var select = $('#ID'),
        xml = $($.parseXML($('#XMLData').text())),
        plans = xml.find('plan');

    plans.each(function () {
        var ID = $(this).find('ID').text();
        select.append("<option>" + ID + "</option>");
    });

    $("#ID").change(function () {
        var selectedIndex = $('#ID option').index($('#ID option:selected')),
            plan = $(plans[selectedIndex]);

        $('#planNumber').val(plan.find('planNumber').text());
        $('#Area').val(plan.find('Area').text());
        $('#Name').val(plan.find('Name').text());
        $('#Description').val(plan.find('Description').text());
        $('#Station_ID').val(plan.find('Station_ID').text());

        $('#code').val(plan.find('code').text());
        $('#County').val(plan.find('County').text());
    }).trigger('change');
});
</script>

<script type='text/xml' id='XMLData'>
  <XMLReview>
    <plan>
      <planNumber>773</planNumber>
      <Area>Upper Missouri</Area>
      <ID>MISSOURI-NUT</ID>
      <Name>Missouri River</Name>
      <code>10030101</code>
      <County>Broadwater</County>
      <Station_ID>M09MISSR05</Station_ID>
    </plan>
    <plan>
      <planNumber>774</planNumber>
      <Area>Columbia</Area>
      <ID>FLAT-STILL-TPA-2013</ID>
      <Name>Sheppard Creek</Name>
      <Description>- 3A</Description>
      <code>17010210</code>
      <County>Flathead</County>
      <Station_ID>C09SHEPC04</Station_ID>
    </plan>
  </XMLReview>
</script>
<form>
    ID <select type="text" name="ID" id="ID"></select><br/>
    planNumber<input type="text" name="Name" id="planNumber"><br/>
    area<input type="text" name="Area" id="Area"><br/>
    Name:  <input type="text" name="Name" id="Name"><br/>
    Description:  <input type="text" name="Description" id="Description"><br/>
    Station ID  <input type="text" name="Station_ID" id="Station_ID"><br/>
    <label class="Code-label" for="code">HUC</label>
    <select class="select_code" id="code" name="code" data-iconpos="left" data-icon="grid">
      <option></option>
      <option>10010001</option>
      <option>10010002</option>
      <option>10020001</option>
      <option>10030101</option>
      <option>17010210</option>
    </select>
    <br/>
    <label class="county-label" for="County">County</label>
    <select class="select_county" id="County" name="County" data-iconpos="left" data-icon="grid">
     <option></option>
     <option>Beaverhead</option>
     <option>Big Horn</option>
     <option>Blaine</option>
    </select>
</form>
$('#result').load('data.xml');
<div id='result'></div>
$.get(url)
  .done(
    function (xml) {
      var $xml = $(xml);
      var plans = $xml.find('plan');
      ...
    }
  );
$(function(){
    var select = $('#ID');
    function renderData(xml,plans){
        plans.each(function () {
            var ID = $(this).find('ID').text();
            select.append("<option>" + ID + "</option>");
        });

        select.change(function () {
            var selectedIndex = $('#ID option').index($('#ID option:selected')),
                plan = $(plans[selectedIndex]);

            $('#planNumber').val(plan.find('planNumber').text());
            $('#Area').val(plan.find('Area').text());
            $('#Name').val(plan.find('Name').text());
            $('#Description').val(plan.find('Description').text());
            $('#Station_ID').val(plan.find('Station_ID').text());

            $('#code').val(plan.find('code').text());
            $('#County').val(plan.find('County').text());
        }).trigger('change');   
    }

    $.get('test.xml',function(data){/// get the xml data from test.xml
        xml = $($.parseXML(data));// parse the data to xml
        plans= xml.find('plan');// find plans from xml
        renderData(xml,plans);//  call renderdata function to render elements
    });
});