Okay, I have 2 drop down list's. One for city one for state. When the user clicks (and makes a selection) for a State the onchange='populateCity()' function is called. The function is part of an included file called at the top of the page:
<script language="JavaScript" src="common/city_dropdown.js"></script>
Now here's my problem:
When a user enters information, the FORM will post the information, check if the user name already exists.... if the user name DOES already exist, all the FORM information gets put into session including city and state:
$_SESSION['city']=trim($_POST['city']);
$_SESSION['state']=trim($_POST['state']);
...then redirects back to the FORM page where all fields are populated with the data the user entered, except for the username and password. Thus telling the user: the username is taken, please select a new username.
However, the city and state fields are not being populated with the user data when this happens. I think my problem is passing the session information into javascript... so that then the "city_dropdown.js" include file can populate the city/state drop down lists.
At the top of "city_dropdown.js" I do this for a check:
var postCity = '<?= $_SESSION["city"] ?>';
var postState = '<?= $_SESSION["state"] ?>';
function populateState(defaultState) {
if ( postState != '' ) {
defaultState = postState;
}
..... other code
}