Reputation: 13
So, I have a 2 select tags and during the onChange event of the second select tag; I want to pass the values of the 2 select tags
<td>District:
<div>
<select name="district" id="district" onchange="getZone(this.value)">
<option value="ALL">ALL</option>
<?php
include_once 'newcompute.php';
$computation = new newcompute();
echo $computation->getDistrict();
?>
</select>
</div>
</td>
<td>Barangay:
<div id="barangay" name="barangay">
<select onchange="loadReport(barangay.value,district.value)">
<option>Select a Barangay</option>
<option value="ALL">ALL</option>
</select>
</div>
</td>
</tr>
So, I tried doing the onchange="loadReport(barangay.value,district.value)" but I only get a UNDEFINED value for district.value
How do I get loadReport to pass the current selected value of select tag district?
Upvotes: 1
Views: 14473
Reputation: 4617
Try this way
<select onchange="loadReport(this.value,document.getElementById('district').value)">
<option>Select a Barangay</option>
<option value="ALL">ALL</option>
</select>
Upvotes: 0
Reputation: 2668
You can retrieve the other tag in the function itself. No need to pass it from here.
function loadReport(barangayValue)
{
var district = document.getElementById('district');
var districtValue = district.value;
//Your stuff
}
Upvotes: 2