Hello,
I am working with a form whereby results will be displayed based on the day that a user has selected from a dropdown list.
For example, if a user selects Monday or Sunday, the group that will do activities on that day will be displayed. I created arrays for days '$dayOfWeek' and group '$team'. I have been able to make the days appear in a dropdown list.
My problem now is how to make the team that will play on each day appear below it when a particular day is selected. Does anyone know how to fix this or of a better way to do this please?
You can see my code below.
I will appreciate your help please.Code:<!doctype html> <html lang="en"> <head> <meta charset=utf-8> <title>Switching values and record display</title> </head> <body> <?php //this is the arrays for days of the week $dayOfWeek = array(); $dayOfWeek['day1'] = "Monday"; $dayOfWeek['day2'] = "Tuesday"; $dayOfWeek['day3'] = "Wednesday"; $dayOfWeek['day4'] = "Thursday"; $dayOfWeek['day5'] = "Friday"; $dayOfWeek['day6'] = "Saturday"; $dayOfWeek['day7'] = "Sunday"; ?> <?php //the arrays for team $team = array(); $team ['one'] = "year one, year two, year three"; $team ['two'] = "year four, year five,year six "; $team ['three'] = "year three, year two, year one"; $team ['four'] = "year one, year four, year six"; $team ['five'] = "year five, year three, year five"; $team ['six'] = "year one to year six"; $team ['seven'] = "year three, year five, year two"; ?> <!--here is the form--> <form action="" method="post"> <label for="weekDay">Week Day: <br/></label> <select name="Wday"> <option value="select">Select a week day</option> <option value="d1"><? echo $dayOfWeek['day1']?></option> <option value="d2"><? echo $dayOfWeek['day2']?></option> <option value="d3"><? echo $dayOfWeek['day3']?></option> <option value="d4"><? echo $dayOfWeek['day4']?></option> <option value="d5"><? echo $dayOfWeek['day5']?></option> <option value="d6"><? echo $dayOfWeek['day6']?></option> <option value="d7"><? echo $dayOfWeek['day7']?></option> </select> <label for="Group"> <br/><br/> Group:</label> <div> <?php //if a user selects a day of the week above, show the teams for that day if($dayOfWeek['day1']){ echo $team ['one']; } ?> </div> </form> </body> </html>
Thanks in advance.




Reply With Quote