Jump to content

Recommended Posts

Here is the page that I am needing help with: http://gameageddon.com/elitetrainer/pokecenter.php

 

This page used to be super long and you had to scroll for each of the prizes, so I wanted to make it much simpler. I know it can be done also with AJAX/Javascript, but I was having trouble getting the coding to work so I found a php alternative. 

I have it so the players in my tcg can click on each box and the prizes will appear. I got that working, however, the players need to be able to save the images that appear in the box and also highlight the prize underneath. The problem is that any click will instantly close what was in the box.

 

How can I make it so that they can at least click inside of the box and it does not revert the box back to it's default view?

 

Here is a sample of the code from the page:




<style>

#button1:focus~#content #def,
#button2:focus~#content #def,
#button3:focus~#content #def,
#button4:focus~#content #def {display:none;}

#button1:focus~#content div:nth-child(2),
#button2:focus~#content div:nth-child(3),
#button3:focus~#content div:nth-child(4),
#button4:focus~#content div:nth-child(5) {display:block;}

#content {
border:1px dashed black;
color:white;
font-size:10px;
text-align:center;
}

#pokemon,#other,#elite, #champ {display:none;}

</style>

<center><h2>Deck Mastery Rewards</h2></center>
<center>Pokemon (Non Legendary/Mega/Primal) - Please make sure you also have the appropriate pokeball.<br>
Other - Trainers, Gym Leaders, and Other Decks (For Trainers, please make sure to take 100 pokedollars for each mastery.)<br>
Elite - Elite 4 Decks<br>
Champion/Lendary - For Champions and also Legendary, Mega, and Primal Pokemon (Make sure you have master balls for these.)<br>
You will need to refresh for multiple masteries of the same type.<br><br></center>

<center>
<a id="button1" href="#" tabindex="1"><img src="img/icon-cappoke.png" alt=""/></a>
<a id="button2" href="#" tabindex="2"><img src="img/icon-mastother.png" alt=""/></a>
<a id="button3" href="#" tabindex="3"><img src="img/icon-mastelite.png" alt=""/></a>
<a id="button4" href="#" tabindex="3"><img src="img/icon-champleg.png" alt=""/></a>

<div id="content">
<div id="def"><br>Reward cards will appear in this box.<br><br></div>
<div id="pokemon"><br><?php
$card1= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];
$card2= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];
$card3= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];

echo "<img src=" . $card1 . ">\n";
echo "<img src=" . $card2 . ">\n";
echo "<img src=" . $card3 . "><Br>\n";

$term1=explode("/cards/",$card1); $term1b=explode(".",$term1[1]);
$term2=explode("/cards/",$card2); $term2b=explode(".",$term2[1]);
$term3=explode("/cards/",$card3); $term3b=explode(".",$term3[1]);
echo "<i>(deckname) Captured:</i> " . $term1b[0] . ", " . $term2b[0] . ", " . $term3b[0];
?><br><br></div>
<div id="other"><br><?php
$card1= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];
$card2= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];
$card3= $medium[array_rand($medium,1)] . $digits[array_rand($digits,1)];

echo "<img src=" . $card1 . ">\n";
echo "<img src=" . $card2 . ">\n";
echo "<img src=" . $card3 . "><Br>\n";

$term1=explode("/cards/",$card1); $term1b=explode(".",$term1[1]);
$term2=explode("/cards/",$card2); $term2b=explode(".",$term2[1]);
$term3=explode("/cards/",$card3); $term3b=explode(".",$term3[1]);
echo "<i>(deckname) Defeated/Mastered:</i> " . $term1b[0] . ", " . $term2b[0] . ", " . $term3b[0];
?><br><br></div>
<div id="elite"><br><?php
$card1= $medium[array_rand($medium,1)] . $digits[array_rand($digits,1)];
$card2= $medium[array_rand($medium,1)] . $digits[array_rand($digits,1)];
$card3= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];

echo "<img src=" . $card1 . ">\n";
echo "<img src=" . $card2 . ">\n";
echo "<img src=" . $card3 . "><Br>\n";

$term1=explode("/cards/",$card1); $term1b=explode(".",$term1[1]);
$term2=explode("/cards/",$card2); $term2b=explode(".",$term2[1]);
$term3=explode("/cards/",$card3); $term3b=explode(".",$term3[1]);
echo "<i>(deckname) Defeated:</i> " . $term1b[0] . ", " . $term2b[0] . ", " . $term3b[0];
?><br><br></div>
<div id="champ"><br><?php
$card1= $special[array_rand($special,1)] . $digits[array_rand($digits,1)];
$card2= $special[array_rand($special,1)] . $digits[array_rand($digits,1)];
$card3= $regular[array_rand($regular,1)] . $digits[array_rand($digits,1)];

echo "<img src=" . $card1 . ">\n";
echo "<img src=" . $card2 . ">\n";
echo "<img src=" . $card3 . "><Br>\n";

$term1=explode("/cards/",$card1); $term1b=explode(".",$term1[1]);
$term2=explode("/cards/",$card2); $term2b=explode(".",$term2[1]);
$term3=explode("/cards/",$card3); $term3b=explode(".",$term3[1]);
echo "<i>(deckname) Defeated/Captured:</i> " . $term1b[0] . ", " . $term2b[0] . ", " . $term3b[0];
?><br><br></div>
</div>


Edited by snowfun87
Link to comment
https://forums.phpfreaks.com/topic/304432-preventing-a-click-action/
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.