I have 2 inputs forms - Subject and Unit. Units come inside subjects. Example:
- Subject - English, Math
- Unit - Nouns, Tenses, Algebra, Geometry
The units table in the DB has a foreign key from the subjects table.
I am making an admin panel which displays me all the content within a subject + unit combination. My options in the subject dropdown are fetched from the DB. For a given value of a subject, I can do the same for the unit dropdown as well.
Passing the data is where I am stuck. I am using the $_GET to take the value from the subject dropdown and passing it on the unit dropdown. The unit dropdown shows the right values but that is removing the value from the subject dropdown.
$("select.subject").change(function(){
var selsub = $(".subject option:selected").val();
var see = $(".subject option:selected").text();
window.location.href = "index.php?" + "&selsub="+ selsub + "&name=" + see;
});
The JS variables get removed because the page is reloading.
I need a quick jquery way in which I can save this value. Not a pro at PHP, haven't worked with AJAX as such, but any ideas will be helpful.