bodycount Posted July 6, 2010 Share Posted July 6, 2010 Hi All I am looking for a bit of help. What am trying to do is a page where can input 10 pin bowling scores, so what I want to do is to have two drop down menus one to select team 1 and another to select team 2, When you select the first team page refreshes and you have a player list for team 1 , but when I do the same for the second team all the team and players for the first team you have just selected get removed and when I select the first team again the second team and there players disappear. Any help with my problem would be gratefully appreciated. Please see code below. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <?php // open connection include 'connection4.php'; //if(isset($_POST['TEAMNAME']) && $_POST['TEAMNAME']) $TEAMNAME = $_POST['TEAMNAME']; if(isset($_POST['TEAMNAME']) && $_POST['TEAMNAME']) $TEAMNAME1 = $_POST['TEAMNAME']; if(isset($_POST['TEAM2']) && $_POST['TEAM2']) $TEAMNAME2 = $_POST['TEAM2']; if(isset($_POST['TEAMNAME2']) && $_POST['TEAMNAME2']) $TEAMNAME3 = $_POST['TEAMNAME2']; if(isset($_POST['PLAYERNAME']) && $_POST['PLAYERNAME']) $PLAYERNAME = $_POST['PLAYERNAME']; if(isset($_POST['T2PLAYER']) && $_POST['T2PLAYER']) $PLAYERNAME2 = $_POST['T2PLAYER']; ?> <html> <head> <link rel="stylesheet" type="text/css" href="robtest1.css" /> </head> <body> <div id="wrapper"> <fieldset> <legend>Book RMA</legend> <?php include 'menus.php'; ?> <br> <br> <br> <form action="scoresheet_test.php" method="POST"> <div> <div class="mytext3"><b>Team One</b></div> <select name="TEAMNAME" onChange="submit();"> <?php /**************************************************************** * * Team One Selection * /***************************************************************/ echo"<option>$TEAMNAME</option>"; $query1 = "SELECT DISTINCT TEAMNAME FROM teamlist ORDER BY TEAMNAME ASC"; $result1 = mysql_query($query1); $num_rows=mysql_num_rows($result1); while ($row=mysql_fetch_array($result1)) { $TEAMNAME = $row["TEAMNAME"]; echo "<option value=\"$TEAMNAME\">$TEAMNAME</option>"; } echo "</select><br></div>"; $query15 = "SELECT * FROM playerlist where TEAMNAME = '$TEAMNAME1'"; $result15 = mysql_query($query15); if($num=mysql_numrows($result15)) { while ($record = mysql_fetch_array($result15)) { $PLAYERNAME = $record["PLAYERNAME"]; echo "$PLAYERNAME<br>"; } } echo "query15 = $query15"; echo "</form>"; /**************************************************************** * * Team Two Selection * /***************************************************************/ echo "<form action=\"scoresheet_test.php\" method=\"POST\"><div>"; echo "<div class=\"mytext3\"><b>Team Two</b></div>"; echo "<select name=\"TEAMNAME2\" onChange=\"submit();\">"; echo"<option></option>"; $query1 = "SELECT DISTINCT TEAMNAME as TEAM2 FROM teamlist ORDER BY TEAMNAME ASC"; $result1 = mysql_query($query1); $num_rows=mysql_num_rows($result1); while ($row=mysql_fetch_array($result1)) { $TEAMNAME2 = $row["TEAM2"]; echo "<option value=\"$TEAMNAME2\">$TEAMNAME2</option>"; } echo "</select><br></div>"; $query16 = "SELECT PLAYERNAME as T2PLAYER FROM playerlist where TEAMNAME = '$TEAMNAME3'"; $result16 = mysql_query($query16); if($num=mysql_numrows($result16)) { while ($record = mysql_fetch_array($result16)) { $PLAYERNAME2 = $record["T2PLAYER"]; echo "$PLAYERNAME2<br>"; } } echo "Query16 = $query16"; echo "</form>"; ?> </div> </div> </form> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Catfish Posted July 6, 2010 Share Posted July 6, 2010 what is the exact problem: 1. when you select "team 2" the page reloads and the player list for team 1 _disappears_ or 2. when you select "team 2" the page reloads and the _selections_ in the team 1 player list are unselected? if it is 1. i'd imagine you are not passing some data around correctly to maintain the output on the page, or your code is not using correct logic to keep the output on the page. if it is 2. (which i think will happen even if 1. isn't occuring) i'd say that remembering selections in forms over page refreshes is probably either a) client software dependant or b) require something like javascript to maintain the selections/inputs. I know for a fact I had to use some JS on one of my scripts to maintain text input values from submitting a form and then pressing "back" button, but i found this occured under Win32 and not under Linux platform - so it could also be client software controlling it sometimes. Quote Link to comment Share on other sites More sharing options...
bodycount Posted July 6, 2010 Author Share Posted July 6, 2010 The problem is number 1. it also happens the other way around as well if you select team2 and the select team 1 the player list disappears. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 6, 2010 Share Posted July 6, 2010 The problem is number 1. it also happens the other way around as well if you select team2 and the select team 1 the player list disappears. Of course, because of this in your selects: onChange="submit();" Quote Link to comment Share on other sites More sharing options...
bodycount Posted July 6, 2010 Author Share Posted July 6, 2010 That's what i want it to do, You select a team and you get a team members without pressing a button. But I think I am trying something a little to fancy. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.