I don't want a button to submit the information from my dropdown list, so I think onchange would be the best way to submit it instead. But I don't know how to implement that when I'm using href and not value. Is there a way to do this?
I have this for the html:
<a href='index.php'>Home </a>|
<a href='index.php?mode=customers'>List of Customers </a>|
<a href='index.php?mode=movieList&genre=Drama'>Drama Movies </a>|
<a href='index.php?mode=movieList&genre=Adventure'>Adventure Movies </a>|
<select>
<option disabled selected>Popular Movies</option>
<option><a href='index.php?mode=favoriteGenre&genre=Adventure'>Adventure</a>
<option><a href='index.php?mode=favoriteGenre&genre=Romance'>Romance</a>
<option><a href='index.php?mode=favoriteGenre&genre=Drama'>Drama</a>
<option><a href='index.php?mode=favoriteGenre&genre=Comedy'>Comedy</a>
<option><a href='index.php?mode=favoriteGenre&genre=Sci-Fi'>Sci-Fi</a>
</select>
and then the corresponding php for just the dropdown:
case "favoriteGenre" :
$genre = (isset($_GET['genre'])) ? $_GET['genre'] : -1;
// step 1: Define SQL Statement
$sql = "SELECT first_name, last_name, title, `movies`.type, date_out FROM `movies`,`customers` WHERE `movies`.type='".$genre."'";
// obtain data
$movieInfo = getAll($sql);
// define column labels
$movie_labels = array('First Name', 'Last Name', 'Title', 'Genre', 'Date Out');
echo "All instances of rental where the genre is " . $genre . ":";
// display data
displayTable($movieInfo, $movie_labels);
break;
And if this question is answered elsewhere, please just point me in the right direction. I haven't been able to find it anywhere thus far. Thanks!
Instead of keeping links inside options, assign values to options like this -
<a href='index.php'>Home |</a>
<a href='index.php?mode=customers'>List of Customers |</a>
<a href='index.php?mode=movieList&genre=Drama'>Drama Movies |</a>
<a href='index.php?mode=movieList&genre=Adventure'>Adventure Movies |</a>
<select id="movieOptions">
<option disabled selected>Popular Movies</option>
<option value="mode=favoriteGenre&genre=Adventure">Adventure</option>
<option value="mode=favoriteGenre&genre=Romance">Romance</option>
<option value="mode=favoriteGenre&genre=Drama">Drama</option>
<option value="mode=favoriteGenre&genre=Comedy">Comedy</option>
<option value="mode=favoriteGenre&genre=Sci-Fi">Sci-Fi</option>
</select>
<script>
$("#movieOptions").change(function () {
var goTo = this.value;
console.log(goTo);
window.location.href = "index.php?" + goTo;
});
</script>