我有以下脚本,其中包含附加到它的 html 数据:
<script>
$(document).ready(function(){
$('#drug_id').change(function (){
option = $(this).find('option:selected').val();
html='';
htmlhead='';
// alert(option)
$.ajax({
type:"GET",
url:"<?php echo base_url();?>transactions/details_now/"+option,
dataType:"json",
success:function(data){
for(i=0;i<data.length;i++){
// alert(data[i].commodity_name)
html += '<form action="<?php echo base_url()?>transactions/issues" method="post"><tr>\n\
<td><input type="text" id="commodity_name' + i + '" name="commodity_name' + i +'" value="'+data[i].commodity_name+'"/></td>\n\
<td><input type="text" id="transaction_type' + i + '" name="transaction_type' + i +'" value="'+data[i].transaction_type+'"/></td>\n\
<td><input type="text" id="Available_Quantity' + i + '" name="Available_Quantity' + i +'" value="'+data[i].Available_Quantity+'"/></td>\n\
<td><input type="text" id="Quantity_Ordered' + i + '" name="Quantity_Ordered' + i +'" value="'+data[i].Quantity_Ordered+'"/></td>\n\
<td><input type="text" id="batch_number' + i + '" name="batch_number' + i +'" value="'+data[i].batch_number+'"/></td>\n\
<td><input type="text" id="date' + i + '" name="date' + i +'" value="'+data[i].date+'"/></td>\n\
<td><input type="text" id="username' + i + '" name="username' + i +'" value="'+data[i].username+'"/></td>\n\
</tr> <input type="submit" value="Issue"></form>';
}
htmlhead+='\n\
<th>Commodity Name</th>\n\
<th>Transaction Type</th> \n\
<th>Batch Number</th> \n\
<th>Available Quantity</th> \n\
<th>Ordered Quantity</th> \n\
<th>Department</th>\n\
<th>Requestor Name</th>\n\
';
$('#thead').append(htmlhead);
$('#you').append(html);
},
error:function(data){
}
})
});
});</script>
当我单击问题按钮时,我想将输入字段中的值发布到控制器。我该怎么做?