I'm having trouble redirecting a form via JS.
This code (accidentally) works fine as long as there is only one variable:
<SCRIPT language="JavaScript">
<!--
function Page(thisform)
{
with (thisform){
var page = thisform.p.value;
}
}
//-->
</SCRIPT>
<form class="box" action="/user/fave.php" onsubmit="return Page(this);">
Which just adds the variable to the URL and refreshes the page (not sure why or how but I go along with it).
However, if I want 2 variables, it doesn't work. Here's the code I've tried (this first variable is unrelated to the form so I reference it via PHP.)
<SCRIPT language="JavaScript">
<!--
function Page(thisform)
{
with (thisform){
var id = 1
var page = thisform.p.value;
var url = '/users/fave.php?id=' + id + '&p=' + page;
window.location = url;
}
}
//-->
</SCRIPT>
Where the id information was only for testing purposes since I couldn't get it to work. Either way the URL output is: /users/fave.php?p=1 as opposed to the desired: /users/fave.php?id=1&p=1
<form class="box" action="/user/fave.php?id=<?php echo $id; ?>" onsubmit="return Page(this);">
So basically the JS isn't doing anything.
Have raked the internet for redirect help but couldn't find any.
Any advice you could offer would be great.