I have a page with MVC 2 , which I had in .aspx , Javascript code, but since I need to use that page from a < em> widget native to iOS , I want to analyze an XML . I had to remove the Javascript code to a separate file because the &&
, >
and <
do not analyze it correctly, and it does not load the page.
I want to get the value of a DropDownList that is in .aspx from the .js file.
The DropDownList I have it like this:
<%= Html.DropDownList(
Model.RegistrationDocumentTypeKey,
Model.GetDocumentTypes(),
new {
@id = Model.RegistrationDocumentTypeKey,
onchange = "onDocumentTypeChangeAux()",
selectedIndex = 1
}
)%>
I would like to obtain the value of the selected index from the onDocumentTypeChangeAux()
method.
Before moving the Javascript code to the file, it was like this, and it worked:
var ddl = document.getElementById('<%= Model.RegistrationDocumentTypeKey %>');
switch (ddl.options[ddl.selectedIndex].value) ...
But now, this does not work, I tried to change it by only putting the id
, doing it as with jQuery , but I have not succeeded.