2016-06-22 39 views
0
<table class="table table-bordered responsive"> 
      <thead> 
      <tr> 
       <th>Session</th> 
       <th>Bus Route</th> 
       <th>Charges</th> 
       <th>Action</th> 
      </tr> 
      </thead> 
      <?php foreach ($fetchbus as $busfee){?> 
      <tbody> 
      <form action="#" method="post"> 
       <tr> 
       <td> <?php echo $busfee->Session; ?> </td> 
       <td> <?php echo $busfee->Route; ?> </td> 
       <td> <?php echo $busfee->Charges; ?> </td> 
       <td><a href="#" id="<?php echo $row->Route_Id;?>" onClick="getbusdetailsforedit(this.id)" class="">Edit</a></td> 
       </tr> 
       <script type="text/javascript"> 
       function getbusdetailsforedit(id) 
       { 
        ajaxRequest = new XMLHttpRequest(); 
        ajaxRequest.onreadystatechange = function() 
        { 
        if(ajaxRequest.readyState == 4) 
        { 
         var ajaxDisplay = document.getElementById('getbusdetailsforeditview'); 
         ajaxDisplay.innerHTML = ajaxRequest.responseText;  
        } 
        } 
        ajaxRequest.open("GET", "<?php echo base_url();?>account/SetFee/getbusdetailsforedit/" +id, true); 
        ajaxRequest.send(); 

       } 
       </script> 
      </form> 
      </tbody> 
      <?php } ?> 
     </table> 

私が編集ボタンをクリックしたとき、iはすべてのajaxレスポンスを1つのIDで完全に取得しました。私は3つの入力フィールドを持っています:入力フィールドにAJAXレスポンスを表示

<div class="widgetcontent"> 
     <?php echo form_open('account/SetFee/addbusfeedetails/', array('class'=>'stdform stdform2')); ?> 
     <div> 
     <div id="getbusdetailsforeditview" class=""> 

     <p> 
      <label>Session</label> 
      <span class="field"> 
      <select name="session" id="session" class="form-control"> 
       <option value="">Select Session</option> 
       <?php for($i=2000;$i<2020;$i++){ 
       ?> 
       <option value="<?php echo $i."-"; echo $i+1; ?>"><?php echo $i.'-';echo $i+1;?></option> 
       <?php } ?> 
      </select> 
      </span> 
     </p> 


     <p> 
      <label>Route</label> 
      <span class="field"> 
      <input name="route" id="route" placeholder="Enter Route" class="form-control"> 
      </span> 
     </p> 



     <p> 
     <label>Charges</label> 
     <span class="field"> 
      <input type="number" id="charges" name="charges" placeholder="Enter Route Charges" class="form-control"> 
     </span> </p> 
     </div> 

     <p><span class="field"> 
     <input type="submit" value="Update Route" name="submit" class="btn-primary" style="left-margin:50px;" /> 
     </p> 

    </div> 

    <?php echo form_close(); ?> 
    </div> 

私はフェッチしました。しかし、私は特定の入力フィールドにデータを取得し、入力値にそれを表示するにはどうすればよい

var ajaxDisplay = document.getElementById('getbusdetailsforeditview'); 
ajaxDisplay.innerHTML = ajaxRequest.responseText; 

でデータを表示しています。現在、それはあなたが入力フィールドに値を設定するド値プロパティを使用することができ独身ID getbusdetailsforeditview

答えて

関連する問題