Jump to content

div shows queried data, but then page reloads.


turpentyne

Recommended Posts

I have a catch-22. I built a simple page that pulls several items from the database, and lists them. Now I need to add a "pop-up" div that shows detailed information for an item, if they click on it. I have it working right now, but instead of reloading the page with the div showing and done, it somehow shows the div with the information from the database, then reloads the page without it showing.

 

I'm not quite sure how I can send the info to the javascript

 

 

<!-- the simple javascript at top of page -->
<script type="text/javascript">
function showdiv(id){
document.getElementById(id).style.display = "block";
}
</script>

<?php 

/* other code that pulls the initial information here */

/* including... this, where the _get id is passed, and includes the call to the javascript function that shows */
$ExpandImageTemplate = <<<OutHTML
<div style='width:70px;padding:15px 15px 5px 10px;float:left;width:150px; min-height:140px;overflow:auto;'> %4\$s <br>
<a class'hide' href="http://www.mcmillanusa.com/mcmillan-rifles-alias-accessories.php?id=%4\$s" target="_self" onclick="showdiv('pop-div');" ><img src="%3\$s" style="border: solid 0px #000000;max-width:150px;"></a></div>
OutHTML;

/* taking some query results to create the above - irrelevant to the question */
$Output .= sprintf ($ExpandImageTemplate, htmlspecialchars ($row['comp_cat_name']),htmlspecialchars ($row['folder_path']),htmlspecialchars ($row['image_filepath']),htmlspecialchars ($row['component_name']));


?>
<!-- then, further down on the page, here's the code that I was trying to write to create the pop-up div I couldn't put it above because it's screwing up a database query for other unrelated stuff -->
<?php 
/* still need to add security for the _get statement, but on page reload, this variable $which_one is set  */

$which_one = ($_GET["id"]); 

$result = mysql_query("SELECT *
FROM `tbl_components`
WHERE `component_name` = '$which_one'")
or die(mysql_error());  

$row = mysql_fetch_array( $result );

echo "<center><div id=\"pop-div\" style=\"display:none;width:700px;z-index:99;height:0px;overflow:visible;color:#000;\"><p style=\"position:relative;left:-48px;background-image: url('../../images/alias/alias-pop-bg.png');width:605px;height:400px;padding:10px;\"><b><span style=\"width:200px;\"><font style=\"color:#fff;\">".$row['component_name']."</font></b><br><br>";
echo "<font style=\"color:#fff;\">".$row['component_description']."</font>>/span><br><br>";
echo "<img src='".$row['image_filepath']."'><br></p></div></center></div>";

?>



 

 

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.