Jump to content

[SOLVED] onClick open document in same window with parsed values


AndieB

Recommended Posts

Hi all,

 

I've created the following PHP script:

<?php
$bgcolor = "#aabbcc";
while ($sqlRows = mysql_fetch_assoc($sqlResult)) {
$bgcolor = ($bgcolor == "#aabbcc")?"#ffffff":"#aabbcc";
	echo "<tr style=\"background-color: " . $bgcolor . "\" onMouseOver=\"style.backgroundColor='#D87093'\" onMouseOut=\"style.backgroundColor='" . $bgcolor . "'\" onClick=\"document.open('event_info.php?e=" . $sqlRows["e_id"] . "', '')\" >\n";
	echo "<td id=\"listLeft\" ><a href=\"event_info.php?e=" . $sqlRows["e_id"] . "\" target=\"_self\" >" . $sqlRows["e_date"] . "</a ></td >";
	echo "<td id=\"listMiddle\" ><a href=\"event_info.php?e=" . $sqlRows["e_id"] . "\" target=\"_self\" >" .  $sqlRows["e_city"] . "</a ></td >";
	echo "<td id=\"listRight\" ><a href=\"event_info.php?e=" . $sqlRows["e_id"] . "\" target=\"_self\" >" . $sqlRows["e_country"] . "</a></td >\n";
	echo "</tr >\n";
}
?>

 

My problem is that when I click the row it does only open a BLANK page.

I want it to open the event_info.php file and send the value with it so the PHP script can run through the database and fetch the data in order to present it.

 

But again, my result above only creates a BLANK white page.

 

What am I doing wrong?

 

Thankful for any kind of help!

 

Sincerely,

 

Andreas

 

Link to comment
Share on other sites

use window.open(); not document.open()

 

Thank you for your answer.

But window.open() opens up a brand new window.

 

I want the page to be opened in the same window, just like if I was using a  <A HREF...> TAG, but it should act when clicking on the ROW in the TABLE.

 

Sincerely,

Andreas

 

 

Link to comment
Share on other sites

do this then (use document.location.href):

 

<?php
$bgcolor = "#aabbcc";
while ($sqlRows = mysql_fetch_assoc($sqlResult)) {
$bgcolor = ($bgcolor == "#aabbcc")?"#ffffff":"#aabbcc";
      echo "<tr style=\"background-color: " . $bgcolor . "\" onMouseOver=\"style.backgroundColor='#D87093'\" onMouseOut=\"style.backgroundColor='" . $bgcolor . "'\" onClick=\"document.location.href='event_info.php?e=" . $sqlRows["e_id"] . "'\" >\n";
      echo "<td id=\"listLeft\" ><a href=\"event_info.php?e=" . $sqlRows["e_id"] . "\" target=\"_self\" >" . $sqlRows["e_date"] . "</a ></td >";
      echo "<td id=\"listMiddle\" ><a href=\"event_info.php?e=" . $sqlRows["e_id"] . "\" target=\"_self\" >" .  $sqlRows["e_city"] . "</a ></td >";
      echo "<td id=\"listRight\" ><a href=\"event_info.php?e=" . $sqlRows["e_id"] . "\" target=\"_self\" >" . $sqlRows["e_country"] . "</a></td >\n";
      echo "</tr >\n";
   }
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.