Im pretty new with javascript programming.
I have some .php code where 2 drop-down lists (in the same FORM) are populated with two different mysqli queries, this works without problems.
I'm trying to get javascript to handle selected parts of dropdowns, with onchange, this only works for one dropdown, and I can't figure out how to get around this.
This is a code that works with a single drop-down menu, and automatically refreshes the page without sending:
$chosen_location = $_GET['Lid']; $chosen_car = $_GET['Cid']; ?> <script type="text/javascript"> function changeDropDown(dropdown){ var location = dropdown.options[dropdown.selectedIndex].value; *var car = dropdown.options[dropdown.selectedIndex].value;* document.getElementById("form1").action = "test.php?Lid=" + location + "&Cid=" + car; document.getElementById("form1").submit(); } </script>
Part of the .php code:
<select size="1" name="form_location_id" id="form_location_id" onchange='changeDropDown(this);'> <option value = <?php echo ($location_id) ?> selected><?php echo ($location_name) ?></option> <select size="1" name="form_car" id="form_car" onchange='changeDropDown(this);'> <option value = <?php echo ($car_type_id) ?>><?php echo "" . ($car_class) . " - " . ($car_manufacturer) . " - " . ($car) . "" ?></option>
The icon in italics, I know, will not catch the correct value, but it is here im right now ...
How can I get the action url with selected values? since this will be used in mysqli query to display data from the actual selection
Thanks in advance...:)
source share