Reputation: 1
I have a dropdown and a set of two radio buttons. When a dropdown value alongwith a radio opotion is selected I need to show a table with the corresponding values fetched. The data is fetched from CouchCMS backend.
<select id='dd_icp'>
<option value="ET" >ET</option>
<option value="NGP" >NGP</option>
<option value="GCC" >GCC</option>
</select>
<label for="f_to_ho0">
<input type="radio" name="f_to_ho" id="f_to_ho0" value="0" checked="checked">T/O
</label>
<label for="f_to_ho1">
<input type="radio" name="f_to_ho" id="f_to_ho1" value="1"> H/O
</label>
<table>
...
</table>
$(document).ready(function() {
$("#dd_icp").change(function() {
var selectedValue = $(this).val();
// Radio???
// Table with data???
});
});
Upvotes: 0
Views: 74
Reputation: 1263
In my answer, to allow me to simply cut and paste an example, I changed the radio button to a selection box, but you would process the radio button in like manner.
Form
<select id="dd_icp">
<option value="" >Select ???</option> <!-- Forces Selection -->
<option value="ET" >ET</option>
<option value="NGP" >NGP</option>
<option value="GCC" >GCC</option>
</select>
<select id="f_to_ho" name="f_to_ho">
<option value="0" >T/O</option>
<option value="1" >H/O</option>
</select>
<div id="results"></div>
Notice the <div id="results"></div>
jQuery
$( "#dd_icp" ).change(function() {
var var_a = $(this).val();
var var_b = $('#f_to_ho').val();
var url = 'path-to-parse.php';
var postit = $.post( url, {var_a:var_a,var_b:var_b});
postit.done(function( data ) {$('#results').html(data);});
});
parse.php
<?php
$var_a = $_POST['var_a'];
$var_b = $_POST['var_b'];
// parse and echo filtered table here
?>
Hope this helps.
Upvotes: 0