Ofir
Ofir

Reputation: 141

Javascript: vars and window.location

I'm pretty new to Javascript. I'm working on a project and I need your help.

        function Function(var i)
    {
        var loca ="uploader.php?last=" +i;
        window.location =loca;
    }  

This code is called using onclick that I set in a html form.. I don't know why, but when I try to run the code it doesn't do anything. Im pretty sure the "+i" is the problem, Im not exactly sure how to add the i. without the "i" the code runs well.

Upvotes: 0

Views: 75

Answers (2)

Manwal
Manwal

Reputation: 23836

You don't have to use var in a function parameter list. Try this:

 function Function(i)//replaced var
    {
        var loca ="uploader.php?last=" +i;
        window.location =loca;
    }  

Upvotes: 1

Naveen Kumar Alone
Naveen Kumar Alone

Reputation: 7678

Modify it as

function Function(i)
{
    var loca ="uploader.php?last="+i;
    window.location =loca;
}

Upvotes: 0

Related Questions