How to redirect end user to another web page using jquery

Is it possible to reassign the end user when checking / unchecking the boxes? How please

I tried redirecting it get methodusing this code

HTML

<form><input type="checkbox" name="fixee" value="true" style="margin-left:40px;margin-right:3px;" /><input type="checkbox" name="nonFixee" value="true" style="margin-left:10px;margin-right:3px;" /></form>

JQuery

$("input[type='checkbox']").change(function () {
    if ($("input[name='fixee']").prop('checked') && $("input[name='nonFixee']").prop('checked')) {
        alert('2');
    }
    else if ($("input[name='fixee']").prop('checked') && $("input[name='nonFixee']").prop('checked')) {
        alert('3');
    }
    else{
        alert('1');
    }
});

http://jsfiddle.net/eKa8S/9/

I code this in Visual Studio ~means the project root folder.

Any brilliant idea please?

+3
source share
3 answers

you can use window.location = "~/Alertes/Index?fixee=true&nonFixee=true"

0
source

In your example, run the get command:

$("input[type='checkbox']").change(function () {
    if ($("input[name='fixee']").attr("checked") && !$("input[name='nonFixee']").attr("checked")) {
        window.location = "~/Alertes/Index?fixee=true&nonFixee=false";
    }
    else if (!$("input[name='fixee']").attr("checked") && $("input[name='nonFixee']").attr("checked")) {
        window.location = "~/Alertes/Index?fixee=false&nonFixee=true";
    }
    else {
        window.location = "~/Alertes/Index?fixee=true&nonFixee=true";
    }
});

Fiddle

0
source

Try it,

$("input[type='checkbox']").change(function () {
    if ($("input[name='fixee']").prop('checked') && $("input[name='nonFixee']").prop('checked')) {
        window.location.href = '@Url.Action("Action1", "Controller")'
    }
    else if ($("input[name='fixee']").prop('checked') && $("input[name='nonFixee']").prop('checked')) {
         window.location.href = '@Url.Action("Action2", "Controller")'
    }
    else{
        window.location.href = '@Url.Action("Action3", "Controller")'
    }
});
0
source

All Articles