Этот код выводит то, что я ввожу в текстовое поле, которое будет отображаться при нажатии кнопки. Но я хочу, чтобы lik , когда я установил флажок, тогда значение, введенное в текстовое поле, будет отображено.
//View page: In this page JQuery for request&Responce type and i am displaying two text box and 1 check box and 1 button
<script type="text/javascript">
$(function(){
$('#selectAll').change(function () {
alert("value changed");//When i run this script only witht this alert function i am getting output but with this code i am unable to get the output what i expect
var options = {
target: '#result-user', // id of the div where we are going to display result
beforeSubmit: showRequest,
success: showResponse,
type: 'post',
resetForm: true
};
$('#form-user').ajaxForm(options); // id of the form we wish to submit
});
});
function showRequest(formData, jqForm, options) {
$("#result-user").empty().html('Loading....');
$("#form-user :input").attr("disabled", true); // disable all form inputs while loading
}
function showResponse(responseText, statusText, xhr, $form) {
$("#result-user").empty().html(responseText);
$("#form-user :input").attr("disabled", false);
}
</script>
</head>
<body>
<% using (Html.BeginForm("Index","Home",FormMethod.Post, new { id="form-user", name="form-user"})) {%>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%= Html.LabelFor(model => model.FirstName) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.FirstName) %>
<%= Html.ValidationMessageFor(model => model.FirstName) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.LastName) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.LastName) %>
<%= Html.ValidationMessageFor(model => model.LastName)%>
</div>
<div>
<input type="checkbox" name="selectl" value="ON" id="selectAll"/>
</div>
<p>
<input type="submit" value="Save" />
</p>
Контрольная страница
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(HomeModel data)
{
return Content("You submitted: " + data.FirstName + " " + data.LastName);
}
}
Страница модели
public class HomeModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Фактическим выводом этого кода является отображение содержимого, введенного в текстовое поле, когда нажимаете кнопку. Но я хочу выводить, как , когда установите флажок, содержимое, которое я ввел в текстовое поле, должно быть оказаны.
Пожалуйста, помогите мне, друзья.