我必须进行选择,当用户从中选择选项时,应根据此选择显示数据库中的数据。我不能用提交。只有在选择此选项时才会显示,以显示此选择的数据。我是jQuery的新手,我不能这样做。我的观点是:
<?php
public function average_price_by_week() {
$this->db->select(*);
$this->db->from('items');
$this->db->where('size', $size); //this $size should be value from select that user has selected
$query=$this->db->get();
return $query->result_array();
}
?>
我的模特是:
Private databaseConnector As DatabaseConnector
Dim fulltxtSQL As String
DatabaseConnector = New DatabaseConnector
Try
fulltxtSQL = "insert into [user-table] (username, password) VALUES ('" & UserName.Text & "','" & Password.Text & "')"
DatabaseConnector.RunSqlNonQuery(fulltxtSQL)
If DatabaseConnector.RunSqlNonQuery(fulltxtSQL) = True Then
MsgBox("thank you for registering ", vbInformation, Title.Trim)
Response.Redirect("Default.aspx")
Exit Sub
Else
MsgBox(MsgBox("There has been a error in your registering", vbInformation, Title.Trim))
End If
Catch ex As Exception
MsgBox(ex.Message.Trim, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Me.Title.Trim)
Exit Sub
End Try
End Sub
答案 0 :(得分:1)
试试这个,它可能对你有帮助。
我使用过JQuery Ajax
。在使用以下代码之前还要包含JQuery library
。
$('#myselect').change(function(){
var size = $('#myselect').val();
if(size != ''){
$.ajax({
type:'post',
url:"/index.php/average_incomes_by_customer/" + size,
cache:false,
success: function(returndata){
console.log(returndata); //"returndata" is the result got from the DB. Use it where you want.
}
});
}
});
控制器:
public function average_incomes_by_customer($size) {
$data['average_price']=$this->receivedOrders_model->average_price_by_week($size);
$this->load->view('charts', $data);
}
型号:
public function average_price_by_week($size) {
$this->db->select(*);
$this->db->from('items');
$this->db->where('size', $size); //this $size should be value from select that user has selected
$query=$this->db->get();
return $query->result_array();
}
感谢。