如何使用jquery发送Textbox Value和Dropdownlist值作为控制器的输入参数? [英] How to send Textbox Value and Dropdownlist value as input parameters for controller using jquery?
问题描述
嗨朋友们,
我需要将文本框输入值和下拉列表选择值传递给MVC4中的Controller ?????????例如:我有一个带有文本框和下拉列表的表单和(用于Webgrid的部分视图)。当我将日期时间输入提供给文本框并在下拉列表中选择DoctorName时。然后我需要将文本框输入值和下拉列表值作为参数传递给控制器???????我的控制器用于绑定PartialView中的webgrid ...我尝试过的代码无效......#doctortype是dropdownlist,#AppointmentDate是Textbox输入日期时间。
Hi Friends,
I need to pass textbox input value and dropdownlist selected value to Controller in MVC4 ????????? For Eg : I have a Form with Textbox and Dropdownlist and ( PartialView For Webgrid) . When i give datetime input to Textbox and Selected the "DoctorName" in Dropdown . Then i need to pass textbox input value and dropdownlist values as parameters to the controller ??????? My Controller is used to bind the webgrid in PartialView... The Code i tried which is not working......#doctortype is dropdownlist,#AppointmentDate is Textbox input datetime.
<script type="text/javascript">
$(document).ready(function () {
$('#doctorType').change(function (e) {
e.preventDefault();
var url = '@Url.Action("Filter")';
$.get(url, { doctorname: $(this).val() }, { AppointmentDate: $('#AppointmentDate').val() }, function (result) {
$('#FilterWebgrid').html(result);
});
});
});
</script>
推荐答案
(document).ready(function(){
(document).ready(function () {
('# doctorType')。change(function(e){
e.preventDefault();
var url ='@ Url.Action(Filter)';
('#doctorType').change(function (e) { e.preventDefault(); var url = '@Url.Action("Filter")';
.get(url,{doctorname:
.get(url, { doctorname:
这篇关于如何使用jquery发送Textbox Value和Dropdownlist值作为控制器的输入参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!