P.Bes P.Bes - 5 months ago 11
CSS Question

By clicking an href img from home.html page i want to show details of that href on page2.html

Firstly i've got a homepage.html in which page are included 10 images with "href" in a table.

My problem is that when I click an image I want to be transferred to the 2nd page where in this page I want to see some information that I provided(it doesn't matter what kind of info). That's the code in 2nd page.

<table width="900px" height="475px" align="center" id="mo1" style="display:none;"><div>
//Table with Info
</div></table>


This table is 1 of 10 tables I've got on my second page which all of them are style="display:none;" So I want to achieve by using Javascript when the image is clicked to proceed me from homepage.html to 2nd page and showing some information by changing the corresponding table to style="display:block;"

P.S Sorry for my bad English I hope you will understand my Problem.. I'm looking for a solution with non JQuery Programming.
Thank You.

Answer

Let's say in homepage.php you have this link that calls secondpage.php and passes the value 'mo1' to identify which table you would like to show:

<a href="http://localhost/secondpage.php?showtable=mo1">image</a>

And in the secondpage.php you have this code that gets the value of $_GET['showtable'] (which is 'mo1') that you will use in the javascript to set the style of the specific table to 'display:block' :

<script>
// set style to display:block
// $_GET['showtable'] = 'mo1'
document.getElementById('<?php echo $_GET['showtable']; ?>').style.display = "block";
<script>

<table width="900px" height="475px" align="center" id="mo1" style="display:none;"><tr><td>//Table with Info</td></tr></table>

I hope you get the idea an adjust according to your needs.

Comments