|
Posted by Mich on 11/11/33 11:25
----- Original Message -----
From: "ZeldorBlat" <zeldorblat@gmail.com>
Newsgroups: alt.comp.lang.php
Sent: 31 August, 2005 03:02
Subject: Re: nOOb question...
> What exactly is the error you're getting?
>
> My guess is that you're getting something about a parse error --
> because you're trying to mix JavaScript with PHP.
>
> Remeber that that JavaScript runs client side -- which means the code
> needs to be output to the browser along with the HTML. I think what
> you really want is something like this:
>
> <?php
> if(isset($_GET['postcode'])) {
> $invoer = $_GET['postcode'];
> ?>
> frames["winkels"].location.href = "storelocator2.php?postcode=" +
> <?
> php echo $invoer; ?>;
> <?php } ?>
>
> The idea is that you can escape between HTML and PHP code and it will
> usually behave as expected. Anything between the <?php and ?> will be
> parsed as PHP; the rest will be sent straight to the browser.
>
Thankx Zeldor,
Had to adjust a little, but got it working in the end.
<?php
if (isset($_GET['postcode']))
{
$invoer = $_GET['postcode'];
?>
<script type="text/javascript">
var whatever = "<?= $invoer ?>";
frames['winkels'].location.href = 'storelocator2.php?postcode=' +
whatever
</script>
<?php
}
?>
For some reason this: frames["winkels"].location.href =
"storelocator2.php?postcode=" +<?php echo $invoer; ?>;
didn't get any characters through, though it did numbers.
Also:
frames['winkels'].location.href = 'storelocator2.php?postcode=' + "<?=
$invoer ?>"
Works well.
Thankx for the help, very much appreciated.
Navigation:
[Reply to this message]
|