Robert, Isn't it to easy to cheat if you do like this? Just view the source and you have the answers. But, this is maybe not for examination, maybe just for learning. If it is examination, AJAX would be better, so that they can not find out the solution by just looking at the source. /Peter -----Original Message----- From: Robert Cummings [mailto:robert@xxxxxxxxxxxxx] Sent: Saturday, August 19, 2006 12:49 AM To: Ryan A Cc: php php Subject: Re: Dhtml/javasript layer tips or software (0.T) On Fri, 2006-08-18 at 08:30 -0700, Ryan A wrote: > Hello, > I am working on a php project that needs a little > extra JS/DHTML solution. I am sure some of you might > have come to use something like this before, please > recommend a solution (commerial solutions are fine / > willing to pay) > > Basically, I will have a page with around 10 questions > for students and then two buttons for [HINT] and > [SOLUTION] > > When either of these buttons/text is clicked the > resulting text should be displayed in the side/bottom > cell, the user should also be able to 'close' this > resulting explanation. > > Note, on each page there will be around 10 questions, > so each of these questions will have a hint & solution > button/text. Will you have two buttons for each question? So that you get the hint/solution on a question by question basis? The solution is quite simple: <html> <head> <script language="javascript" type="text/javascript"> var hints = new Array(); hints[1] = 'Hint for question 1'; hints[2] = 'Hint for question 2'; hints[3] = 'Hint for question 3'; hints[4] = 'Hint for question 4'; //... var solutions = new Array(); solutions[1] = 'Solution for question 1'; solutions[2] = 'Solution for question 2'; solutions[3] = 'Solution for question 3'; solutions[4] = 'Solution for question 4'; //... function showHint( id ) { hideSolution(); var h = document.getElementById( 'questionHint' ); h.innerHTML = hints[id]; h.style.display = ''; } function hideHint() { var h = document.getElementById( 'questionHint' ); h.style.display = 'none'; } function showSolution( id ) { hideHint(); var s = document.getElementById( 'questionSolution' ); s.innerHTML = solutions[id]; s.style.display = ''; } function hideSolution() { var s = document.getElementById( 'questionSolution' ); s.style.display = 'none'; } </script> </head> <body> <p>blah blah blah blah blah blah</p> <p> Question 1 ... <input type="submit" value="Get Hint" onclick="showHint( 1 ); return false;" /> <input type="submit" value="Get Solution" onclick="showSolution( 1 ); return false;" /> </p> <p> Question 2 ... <input type="submit" value="Get Hint" onclick="showHint( 2 ); return false;" /> <input type="submit" value="Get Solution" onclick="showSolution( 2 ); return false;" /> </p> <p> Question 3 ... <input type="submit" value="Get Hint" onclick="showHint( 3 ); return false;" /> <input type="submit" value="Get Solution" onclick="showSolution( 3 ); return false;" /> </p> <p> Question 4 ... <input type="submit" value="Get Hint" onclick="showHint( 4 ); return false;" /> <input type="submit" value="Get Solution" onclick="showSolution( 4 ); return false;" /> </p> <p>...</p> <p id="questionHint" style="display: none;"> </p> <p id="questionSolution" style="display: none;"> </p> </body> </html> I'll leave it to you as an exercise to adapt it properly in PHP using variables and loops instead of harded coded content :) BTW, this is not PHP, but I'm feeling benevolent today ;) Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php