|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
You mean like this?
Code:
function x_y(id1, id2, id3, id4)
{
var queryString = "x_y.php?";
alert(queryString);
var ele = document.getElementById(id1);
if(ele && ele.value != 0)
{
queryString = queryString+""+id1+"="+ele.value;
}
ele = document.getElementById(id2);
if(ele && ele.value != 0)
{
queryString = queryString+"&"+id2+"="+ele.value;
}
ele = document.getElementById(id3);
if(ele && ele.value != 0)
{
queryString = queryString+"&"+id3+"="+ele.value;
}
ele = document.getElementById(id4);
if(ele && ele.value != 0)
{
queryString = queryString+"&"+id4+"="+ele.value;
}
document.location = queryString;
}
No error messages and same thing happens, it just reloads the page but adds ? at the end. Tried it again with xy.php and it works perfectly. Frustrating! |
|
#17
|
|||
|
|||
|
try putting more of the url. like the absolute path. /folder/x_y.php or the full url http://localhost/folder/x_y.php
when I took the original script I wrote and put it in a file called x_y.php everything worked fine. I also tried taking off the filename (take off "x_y.php"+) so it would redirect to just queryString it worked fine also. Last edited by IAmALlama : November 16th, 2009 at 01:54 PM. |
|
#18
|
|||
|
|||
|
Tried both absolute path and and full url, nothing changed.
When I removed my file and left queryString = "?" it still redirected to x_y.php?. Tried it again with xy.php and it works. |
|
#19
|
|||
|
|||
|
and did you alert() the querystring to make sure there wasn't something wrong elsewhere?
Code:
var newURL = "x_y.php" + queryString;
alert(newURL);
document.location = newURL;
|
|
#20
|
|||
|
|||
|
Yup tried that before. Tried your example now aswell. Same thing. Refreshes page and adds ? behind .php.
I have no idea why the script wouldn't allow underline in file names. Edit: Solved, I used a copy of the same function in the same page and both had same Id's, that's why it didn't work. Changed it and now it works perfectly. Thanks for the help! Last edited by AnonG : November 16th, 2009 at 09:59 PM. |
|
#21
|
|||
|
|||
|
As an aside... if you're going to use PHP_SELF for a form action, you should wrap it with htmlentities to avoid XSS attacks.
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Form + javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|