Link to home
Start Free TrialLog in
Avatar of QUANPROFILES
QUANPROFILES

asked on

Match Image

Repost.

I have six images and arrange by two rows and three columns like below

********* * ****************                                                                  
*                 *               *              *                                      
*    Image1  *   Image2  * Image3  *                                                        
*                 *               *              *                                      
********** ******* *********                                                                    
*                 *               *              *                                            
*  Image4    * Image5   * Image6   *                                                              
*                 *               *              *                                      
***************************  

How do we write in JavaScript

Step 1.  Set maximum click for each image is one time only.
           If user click Image1 and image4 then both image1 and image4 disappear
           If not then display message you got this wrong
           
          If user click Image2 and image5 then both image2 and image5 disappear
           If not then display message you got this wrong

           If user click Image3 and image6 then both image3 and image6 disappear
           If not then display message you got this wrong

Step 2.  Show all image if all image matched
              Then display popup dialog or message saying good job!
               
                If one of them is wrong then display you missed 1
                 If two of them is wrong then display you missed 2
                  If three of them is wrong them display you missed all.

Thanks  
Avatar of SweatCoder
SweatCoder
Flag of United States of America image

i don't have time to write out all the code for you, but i know these principles will work:

- declare global js variables outside the scope of any function
- use these vars to hold "number times clicked"
- 1 var for each image
- use <SPAN> or <DIV> to show/hide images. use STYLE="display:none" for hiding, etc. can be done via js as well.
ASKER CERTIFIED SOLUTION
Avatar of arantius
arantius

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QUANPROFILES
QUANPROFILES

ASKER

wow amazingl thanks alot.
Hi arantius can you please rewrite this script, it just a little different.
I have six images and arrange by two rows and three columns like below

********* * ****************                                                                  
*                 *               *              *                                      
*    Image1  *   Image2  * Image3  *                                                        
*                 *               *              *                                      
********** ******* *********                                                                    
*                 *               *              *                                            
*  Image4    * Image5   * Image6   *                                                              
*                 *               *              *                                      
***************************  

How do we write in JavaScript

Step 1.  Set maximum click for each image is one time only.
           If user click Image1 and image4 then both image1 and image4 disappear
           If not then display message you got this wrong
           
          If user click Image2 and image5 then both image2 and image5 disappear
           If not then display message you got this wrong

           If user click Image3 and image6 then both image3 and image6 disappear
           If not then display message you got this wrong

Step 2.  Don't show the old image (keep them disappear)
              If user got them all the display saying good job
           
              If they missed more than three then display the message "you should study more" and popup a new window to studymore.html

Thanks  
How can they get more than three wrong?  They can only click on an image one time, so they can only make 3 tries at a pair.
To keep the images take out the first 3 lines in the finished function.
Oops, not they can click only one time

they may click more then one time for each image as long as they don't miss over three.
If miss three then finish.

to view a full problem please click below
https://www.experts-exchange.com/questions/21227564/MATCHING-IMAGE-TEST.html
THANKS GUYS, WE SOLVED THE PROBLEM.
AGAIN
THANKS