[英]I can not get the value of a textbox on a view in mvc 4 C#
@model IEnumerable<TBWeb.Models.SP_GetALlRoutes_Result>
@{
ViewBag.Title = "Rutas";
Layout = "~/Views/Shared/_Layout.cshtml";
string fecha=string .Empty ;
}
<script language="JavaScript" type="text/JavaScript">
$('#FechaInicio').onchange(function (){
fecha= document.getElementById("FechaInicio").value;
)};
</script>
<input type="text" id="FechaInicio">
@model IEnumerable<TBWeb.Models.SP_GetALlRoutes_Result>
@{
ViewBag.Title = "Rutas";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<input type="text" id="FechaInicio">
<script language="JavaScript" type="text/JavaScript">
$(function() { //wait for doc ready before trying to wire up to element
//use jquery event handler for text change: 'input' event is an on change event
$('#FechaInicio').on('input', function (){
var inicio = $(this).val();//this refers to the FechaInicio element the input event fired on
//send to controller action
$.ajax({
url: @Url.Action("SomeActionName"),
type: 'POST',
data: {
whateverParamNameIsIncontrollerAction: inicio
},
success: function (result) {
//do whatever after request completes
}
});//ajax
)};//on input
)};//doc ready
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.