Hi,
I'm making a website for a friend who sells sports memorabilia and I'm using a LAMP setup. I am making a menu that utilizes AJAX. The menu consists of a SELECT tag, we'll call this SELECT1, where the user clicks it, it drops down a list of leagues such as MLB, NCAA, NFL, etc., which are pulled out from a league MySQL table.
After the league is selected, a SELECT2 appears, where the user selects the conference such as National League/American League, NFC/AFC, etc.
When that is chosen, a list of that conference's teams shows up below.
It works great. Except when the page is refreshed. In that case, the page is re-loaded and the league selection stays there, but it doesn't show the conference SELECT2 tag. And then even if I click on it, nothing happens unless I change the selection, because I have the script that takes care of the conference to be executed during the onchange event in SELECT1.
How do I make it so that even if the page is refreshed, it still knows the value in SELECT1? There isn't any onload event that I know of for it; I tried it.
Here is my code so far:
<?php
include('connect.php');
include('htmlheader.php');
$menuleagueno = $_SESSION['mleagueno'];
$menuteamno = $_SESSION['mteamno'];
//
// echo "<html><body background='bricks2.jpg'>";
echo "
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td background='bricks6.jpg' height=700 valign=top font style: color=white>
<form>
<font color=white>
Select a sports league:<br />";
echo "<select name='league' onload='leagues(this.value)'>";
echo "
<option value=0>Select a sports league:
<option value=0>--------------------------";
$sql = "select * from leagues";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$leagueno = $row['leagueno'];
$leaguedesc = $row['leaguedesc'];
echo "<option value=$leagueno>$leaguedesc";
}
echo " </select></p>
</font>
</form>
<span id='results'></span>
</td>
</tr>
</table> ";
echo "</body></html>";
// include('htmlfooter.php');
?>
This file is called menu.php. I include this in the main pages, and position it on the left.
My next question is how do I (without using frames) retain the value of what's in the SELECT tags in menu.php? I tried doing
$menuleagueno = $_GET['leagueno'];
$menuteamno = $_GET['teamno'];
include('menu.php?leagueno=$menuleagueno');
to test to see if this method would work, and it didn't. It gave me a syntax error, and treated the whole line as a filename, it said it couldn't find the file. So without putting menu.php in its own frame, how would I keep the menu intact, going from page to page? Constantly having to go through it and select your team would get very annoying to a user.
I hope I described this in sufficient detail, if not, I apologize in advance, and will do my best to do so if you need further clarification.
Thanks,
Diode