My Producer model has Id and Name
Movie model has Title and Producer as property.
My index.html :
<select id="selectMovieProducer">
</select>
I have following event
$("body").ready(function(){
var requestUrl = host + port + moviesEndPoint;
$.getJSON(requestUrl, setMovies)
});
setMovies function from the code above generates (appends) a table with all movies, and then a <option> element for each Producer (appends to <Select> from HTML). Each <option> has value property set to Producer's Id while displaying its Name (in a dropdown/select).
Im working on this event to POST new movie:
$("#movieForm").submit(function(e){
e.preventDefault();
var title = $("#movieTitle").val();
var genre = $("#movieGenre").val();
var premierYear = $("#moviePremierYear").val();
var producerId = ???
});
How do i get/access value property of the selected <option> ?
I need it so i can create a movie object and send it to my post method.