Jump to content

xn1

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xn1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank-you for the responses. I was aiming to have the label tags outside the table cell tags, so that clicking the cell checked the checkbox. But it only works in ie.
  2. Can anyone tell me why the following works in IE but nothing else? <label><td>Clicking this cell selects the checkbox</td></label> Consider me confused.
  3. Is there no other way than Js? Seems strange that html will let the image be the label and highlight the checkbox when your over the image but it won't let you select it
  4. Hi all, I'm using an image as a checkbox label and I'm having a strange problem. When you move the mouse over the image, the associated checkbox highlights (as it should). However, clicking the image does not select the checkbox and I can't figure out why. Is this function not possible?
  5. First question: is the third line of code here even nessesary $_SESSION['asked']=array(); $catagories = array("easy", "medium", "hard"); $random = $catagories[mt_rand(0, count($catagories)-1)].mt_rand(1,5); while(in_array($random, $_SESSION['asked'])) { $random = $catagories[mt_rand(0, count($catagories)-1)].mt_rand(1,5); } $_SESSION['asked'][] = $random; This then generates one of 15 options (currently), those being easy1, easy2, easy3, easy4, easy5, medium1, medium2, medium3, medium4, medium5, hard1, hard2, hard3, hard4, hard5. My second question is, can I give this generator the ability to generate hard6, hard7, hard8, hard9 and hard10, while not generating anything higher than 5 with easy and medium?
  6. I've just figured it out actually, thank you for the help
  7. Sorry about this, i must be appropriating what you are saying wrong, I've done the below but I'm getting server errors if(isset($_POST['submitbutton'])) { $_SESSION['asked']=array(); $catagories = array("easy", "medium", "hard"); function CheckExsits($catagories, $_SESSION['asked']) { mt_srand((double)microtime()*1000000); $random = $catagories[mt_rand(0, count($catagories)-1)].mt_rand(1,5); return (in_array($_SESSION['asked'], $catagories)) ? CheckExsits($catagories, $_SESSION['asked']): $random; } header ("Location: $random.php"); }
  8. Sorry, you've lost me with haystack I'm currently using this to create my random string On a page load I create a string with... $catagories = array("easy", "medium", "hard"); $rand_key = array_rand($catagories, 1); $rand_catagory = $catagories[$rand_key]; $rand_number = mt_rand(1,5); Then if I were echo $rand_catagory.$rand_number it would show hard1 or easy3 or medium4 etc. So upon creating the very first string it adds to the array with $_SESSION['asked'][]=$rand_catagory.$rand_number; Now upon creating the next string on new a page refresh, I want it to the check is the newly created string exists in the $_SESSION['asked'] array. If it exists already, try making a new string and see if that exists in the $_SESSION['asked'] array. Upon finding one that isn't in the array add it too the array and continue process the rest of my script. Hope that explains myself well.
  9. Well, I'm trying to create the code, I want it to generate the random string, check to see if that string exists in the SESSION['asked'] array, if it does already exist, make up a new string and keep making them until it finds one that doesn't. When it creates a string that isn't in the array, add the created string to the array. and continue processing.
  10. Thank you for the quick response. Will this keep generating strings until it finds one not in the $_SESSION['asked'] array?
  11. Can anyone help me with the following please. Upon loading the page, I want to generate a random string based of the following... Select one value from the following array $categories = array("easy", "medium", "hard") And generate a random number from one to five. The string would then look like hard1 or easy5 etc.. Then check if the string generated exists in the following session array $_SESSION['asked'] If not, add it to that array and continue, if it is, create a new random string and check if that one exists and loop until its found one that isn't. Thank you in advance
  12. Ok, what I've done then is create a starting page where I've set a session array called answers and a session variable to count the number of questions aswered (this will be so that eventually I can keep loading random questions until i hit a target then go to a results page) called qcount. Am I doing it right now? This is after you click on start test in the start page. (This is question1.php) <?php session_start(); $errorFound = false; $errorIcon['question1'] = ''; if(isset($_SESSION['qcounter'])){ if(isset($_POST['submitbutton'])){ if($_POST['question1'] = ''){ $errorFound = true; $errorIcon['question1'] = 'Please Select An Answer'; } if(!$errorFound){ $_SESSION['answers'][] = $_POST['question1']; $_SESSION['qcounter'] = $_SESSION['qcounter']+1; header ("Location: question2.php"); } } } else { header ("Location: teststart.php");} ?>
  13. Had to change it slightly to remove the .php but it did work perfectly thank you. So I'd only need session start in the first page? And would I only need to define the array on the first page too? On the results page I plan on explaining all of the answers that were wrong by checking them all. Would I be able to do this with the array?
  14. First question, what am I doing wrong? The aim of the functions is to, test the answer to the question on the page, to make sure an option is selected, if selected move on to the next while storing the answer into a session. What's the easier way? Second question, can you link me a guide to the ?file=hazard2 way of doing things. And thank you for the file name help.
  15. As you can see here I have the following code <?php session_start(); session_register('hazard2'); //INITIALIZE ERROR VARIABLES $errorFound = false; $errorIcon['hazard2'] = ''; if (isset($_POST['submitbutton'])) { //SET SESSION VARIABLES $_SESSION['hazard2'] = $_POST['hazard2']; //TEST FORM INFORMATION if(count($_POST['hazard2']) != 3) { $errorFound = true; $errorIcon['hazard2'] = 'Error Question 2'; } //IF NO ERRORS WERE FOUND, CONTINUE PROCESSING if (!$errorFound) { header( "Location: hazardresult.php" ); } } ?> It's lazy I know, but the script is on a file called hazard2.php, is there anyway to have all of the hazard2's in the code come from the file name. So when I make hazard3, I don't have to change all the hazard2's to hazard3's Thank you
×
×
  • 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.