Question

I am using RouteUrl for window.location.href in MVC3 with JavaScript after clicked CheckBox, I have Multiple checkBox, i am taking all checked checkbox values in selectedValues then passing in RouteUrl as a parameter but its giving error...

<script type="text/javascript" language="javascript">
//Get value of selected items
function GetSelectedValue() {

    var selectedValues = [];

    $("[id*=CheckBoxList1] input:checked").each(function () {
        selectedValues.push($(this).val());
    });

    var s = sele.tos();

    if (selectedValues.length > 0) 
    {
        // alert("Checkbox selected value(s): " + selectedValues);

     window.location.href = 'Url.RouteUrl("MultipleManufacturer", new { manufacturerId = selectedValues })';

    } 
    else
    {
        alert("No item has been selected.");
    }
}

Was it helpful?

Solution

I got the answer...

function GetSelectedValue() {

    var selectedValues = [];

    $("[id*=CheckBoxList1] input:checked").each(function () {
        selectedValues.push($(this).val());
    });


    if (selectedValues.length > 0) {

        var url = '@Url.RouteUrl("MultipleManufacturer", new { manufacturerId = "_documentId_"})';
        var finalUrl = url.replace('_documentId_', selectedValues);

        window.location.href = finalUrl;

    } 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top