Get value from dropdown list en use value in UrlHelper

I would try something like this, but it is not allowed.

function GetDynamicModulesProperties() {
    var selectedValue = $("#moduletype option:selected").val();
    if (selectedValue.lenght() > 0) {

        var url = '<%= Url.Action("GetModuleProperties", new { sectionid = ViewData.Model.Id, moduleTypeId = selectedValue } ) %>';
        var renderContainer = $("#modulesettings");
        $.get(url, function(data) {
            renderContainer.html(data);
            renderContainer.fadeIn('slow');
        });
    }
}

      

Is there a way to do this?

Thanx in advance

+1


source to share


1 answer


run the val () command to select the selected option value.

var selectedValue = $("#moduletype").val();

      



to get it from the option you would use, however no extra key presses :)

 var selectedValue = $("#moduletype>option:selected").attr('value');

      

0


source







All Articles