Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
67
rated 0 times [  71] [ 4]  / answers: 1 / hits: 28517  / 9 Years ago, fri, june 19, 2015, 12:00:00

I have the following script which works fine:



if(error1 == 1){
window.alert('You have already signed up!');
window.location.replace('index.php');
}


But when I want to use the following URL instead of index.php, it does not substitute the parameters:



if(error1 == 1){
window.alert('You have already signed up!');
window.location.replace('http://polimovie.deib.polimi.it/Version3/index.php?campaign=.$Campaign_id.&worker=.$Worker_id.');
}


This code, redirects me to http://polimovie.deib.polimi.it/Version3/index.php?campaign=.$Campaign_id.&worker=.$Worker_id. while I need the parameters be replaced with their actual numbers.



I know I can use php header, I also used it within my php codes like this and with both it workerd fine:



echo <script>alert('PLEASE SIGN UP FIRST!');window.location = 'http://polimovie.deib.polimi.it/Version3/index.php?campaign=.$Campaign_id.&worker=.$Worker_id.';</script>;


but I would like to know how I can use parameters with window.location.replace.



Thanks,


More From » php

 Answers
6

Try as below :



if(error1 == 1){
window.alert('You have already signed up!');
window.location.replace('http://polimovie.deib.polimi.it/Version3/index.php?campaign=<?php echo $Campaign_id; ?>&worker=<?php echo $Worker_id; ?>');
}


Above will work if this is a php file and not js file


[#66134] Thursday, June 18, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaden

Total Points: 709
Total Questions: 91
Total Answers: 91

Location: Maldives
Member since Sat, Jan 29, 2022
2 Years ago
jaden questions
Tue, Jun 29, 21, 00:00, 3 Years ago
Sun, Jul 5, 20, 00:00, 4 Years ago
Fri, May 29, 20, 00:00, 4 Years ago
Wed, May 27, 20, 00:00, 4 Years ago
;