2011-02-17 67 views
0

如何從MySQL數據中選擇要填充的選項?它填充到一個textarea就好了,當一個虛擬選項被選中。如何從MySQL數據中選擇要填充的選項?

<html> 
<head> 
<title>Populate Dropdown...NOT</title> 
<link rel="stylesheet" type="text/css" href="load2.css" media="screen"> 
<script src="http://code.jquery.com/jquery-1.4.4.js"></script> 

<script type="text/JavaScript"> 
$(function() { 
    $('#nameSelect').change(function() { 
     $.get('getDetails.php', {name: $(this).val()}, 
      function(data) { 
       $('#details').val(data); 
      } 
     ); 
    }); 
}); 
</script> 
</head> 
<body> 

<div class="right"> 
<p> 
<table border="1" bgcolor="#DDDDDD">  
    <tr> 
    <td>Use Existing Asset ID:</td> 
    <td><select name="name" id="nameSelect" style="width:95px;"> 
     <option>Ford</option> 
     <option>Chevy</option> 
      </select></td>  
    </tr> 
    <tr> 
     <td>Existing Ticket Status: </td> 
     <td><input type="text" size="12" maxlength="36" id="ticket_status" name="ticket_stat"></td> 
    </tr> 
    <tr> 
     <td>Existing Prob. Desc: </td> 
     <td><input type="text" size="12" maxlength="36" id="problem_desc" name="problem_desc"></td> 
    </tr> 
    <tr> 
     <td>Existing Priority Code: </td> 
     <td><input type="text" size="12" maxlength="36" id="priority_code" name="priority_code"></td> 
    </tr> 
</table> 
</p>  
</div> 

<div id="Div4"> 
    <textarea id="details" rows="20" cols="40"></textarea> 
<div> 

</body> 
</html> 

回答

0

一種方法是創建一個返回結果的JSON arary服務器端AJAX功能,然後爲每個結果需要$('#yourSelect').append('<option>'+returnedArray[i]+'</option>')

數組中
相關問題