I have a Jquery code that listens for the selection from a user and displays the information that the user needs. The user selects a "folder" and then the content appears after they selected.
There are 2 pages. The first page has the jquery code and the selection box and the div that the information is the be displayed in. Our problem is I got the folder name to pass but I need to pass along the $username as well so that it knows what folders to look up.
This is the first page. It's the selection box and also jquery code.
<script type="text/javascript" src="jquery-1.9.1.min.js">
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#theselect").change(function() {
var option = $(this).val();
$.get("selectfolders.php", {select:option},function(data){
$("#theresult").html(data).hide().fadeIn(1000);
});
});
});
</script>
echo "
<select name='thename' id='thename' style='visibility:hidden;' >
<option value='$username'>$username</option>
</select>";
?>
<select name="theselect" id="theselect">
<option value="">Select</option>
<?
$thelistquery = mysql_query("SELECT * FROM folders WHERE username='$username'");
while ($lrows = mysql_fetch_array($thelistquery)) {
$id = $lrows['ID'];
$username = $lrows['username'];
$foldername = $lrows['foldername'];
$newfoldername = mysql_real_escape_string($foldername);
echo "<option value='$newfoldername'>$newfoldername</option>";
}
?>
</select>
This is the second page. It generates the list of folders and displays the folder the user selects on the first page:
$thelistquery = mysql_query("SELECT * FROM folders WHERE username='$username'");
while ($lrows = mysql_fetch_array($thelistquery)) {
$id = $lrows['ID'];
$username = $lrows['username'];
$foldername = $lrows['foldername'];
$newfoldername = mysql_real_escape_string($foldername);
if($_GET['select'] == '$newfoldername') {
echo "This is the $newfoldername folder.";
}
}
We need to add code the the javascript to take the $username from the first page and pass it to the second page so it knows whose folders to look up. Any help?