Reputation: 93
I am using the css dropdown list for city how to pass the selected value of city to model in view
<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("/UserRegistration/CreateEducator", { city: cityTextValue });
Upvotes: 1
Views: 92
Reputation: 368
It's very simple. In Java EE we generally use request.getparameter("parameter name") to retrieve values from views. The only thing you are required is to give a name to your input, select or drop down list.
Upvotes: 1
Reputation: 5545
use onchange
event for Select
.
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
Upvotes: 0