0

Hi all,

Just wondering if anybody can spot the syntax error with the below.

'<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button>'

It works fine when I just append one row to the URL like this

'<button type="button" onclick="window.location=\'results.php?id='. $row['proposalid'] . '\'">Book Now</button>'

The button only stops workin when I append the second 'hotelname' row.

Think its just a syntax error but I cant manage to spot it.

Any suggestions would be much appreciated.

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by smartness
0

Hi pritaeas

Oh sorry I should have said in my post.

When I click on the button it doesnt call bookview.php, it doesnt call any page!

Thanks

Sorry can I also just mention that I made a mistake there in my original post both examples of code I gave should be pointed towards bookview.php and not results.php as I have in my second example.

Edited by debuitls: mistake in original post

0

Not sure, if I put this:

<button type="button" onclick="window.location='bookview.php?id=1&hn'">Book Now</button>

in a test.html file it tries to open bookview.php

Are you missing something else ? Or do you have javascript disabled ?

Edited by pritaeas: n/a

0

This works for me, this sent me to:
http://localhost/bookview.php?id=4&hn=victory

<?php 
$row['bookingref'] = "4";
$row['hotelname'] = "victory";
echo '<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&amp;hn='. $row['hotelname'].'\'">Book Now</button>'
	  
?>

Edited by smartness: n/a

0

Not a window.location. It's wrong ))
window.location.href = '' or window.location.reload(URL);

Edited by SAMAEL: n/a

0

Thanks for your suggestions guys.

Just resolved this.

The syntax

'<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button>'

was fine as was suggested.

The problem was that the value I was appending to the URL had a comma in it.

silly mistake

Thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.