[英]Is there any way to pass the javascript value to model in view
I am using the css dropdown list for city how to pass the selected value of city to model in view 我正在使用城市的css下拉列表如何将选定的城市值传递给视图模型
<span class='selected' id="SelectedCity">select City</span>
the selected value is in span how to pass the span value to model ? 选定的值在范围内如何将范围值传递给模型?
I have used $.post
method but it hits the action method twice second time it takes the value null for city 我已经使用了
$.post
方法,但是第二次击中了action方法两次,它需要为city取值null
$.post("/UserRegistration/CreateEducator", { city: cityTextValue });
It's very simple. 非常简单 In Java EE we generally use request.getparameter("parameter name") to retrieve values from views.
在Java EE中,我们通常使用request.getparameter(“ parameter name”)从视图中检索值。 The only thing you are required is to give a name to your input, select or drop down list.
您唯一需要做的就是为输入名称,选择或下拉列表。
use onchange
event for Select
. 为
Select
使用onchange
事件。
write script like this 这样写脚本
function GetSelectedItem()
{
var e = document.getElementById("select");
var cityTextValue = "The Value is: " + e.options[e.selectedIndex].value + " and text is: " + e.options[e.selectedIndex].text;
alert(cityTextValue );
}
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.