Date: 12/11/2013 10:27:41
From: JTQ
ID: 429430
Subject: PHP/Javascript help?

Hi, hopefully someone here knows how to solve this?

——————-
alert(\“Please fill in all required fields.\”); window.location.href = “.$page_location.”; </script>”;
?>
——————-

Can someone please correct this? It’s not working :( First of all I’m not sure if I can direct to a URL drawn from a variable?

Reply Quote

Date: 12/11/2013 10:29:46
From: JTQ
ID: 429431
Subject: re: PHP/Javascript help?

Bugger… try again

<?php
$page_location = ‘designer.php’;
echo “<script language=\“javascript\” type=\“text/javascript\”>
alert(\“Please fill in all required fields.\”);
window.location.href = “.$page_location.”;
</script>”;

?>

Reply Quote

Date: 12/11/2013 10:50:42
From: JTQ
ID: 429443
Subject: re: PHP/Javascript help?

Nevermind then… sorted it out myself :)

Reply Quote

Date: 12/11/2013 11:13:58
From: Michael V
ID: 429446
Subject: re: PHP/Javascript help?

JTQ said:


Nevermind then… sorted it out myself :)
And the solution (for those of us who couldn’t figure it out) is?

Reply Quote

Date: 13/11/2013 14:55:33
From: fsm
ID: 430265
Subject: re: PHP/Javascript help?

You have probably already realised that nesting multiple sets of quotation marks is a big pain. You could do it like this…

<?php $page_location = ‘designer.php’; ?>
<script language=“javascript type=text/javascript>
alert(“Please fill in all required fields.”);
window.location.href = “<?php echo $page_location; ?>”;
</script>

But for this code snippet the PHP is not actually doing anything, so why not just output it all as straight HTML?

Reply Quote