以下代码显示单选按钮行以及其他输入字段。我的问题是,当选择一个单选按钮时,如何获取其他输入字段的值。我正在使用Code Igniter。
这是视图。
<table class="table table-hover">
<tr><th>Time</th><th>Fare</th><th>Seats Available</th><th>Seats Required</th></tr>
<?
$slno = 0;
foreach ($cab_schedule->result() as $row)
{
if($row->current_seat_available == 0) {
?>
<? //=$row->car_schedule_id?>
<tr>
<td>
<input type="radio" name="slno_<?=$slno?>" id="slno_<?=$slno?>" value="<?=$row->journey_time?>
<?=$row->datetime_ampm?>" disabled="true"> <?=$row->journey_time?> <?=$row->datetime_ampm?>
</td>
<td>
<input type="text" name="fare_" value="<?=$row->fare?>" readonly="true"><?=$row->fare?>
</td>
<td>
<?=$row->current_seat_available?> No(s).
</td>
<td>
Not Applicable
</td>
</tr>
<? } else { ?>
<tr>
<td>
<input type="radio" name="slno_<?=$slno?>" id="slno_<?=$slno?>" value="<?=$row->journey_time?> <?=$row->datetime_ampm?>" />
<?=$row->journey_time?> <?=$row->datetime_ampm?>
</td>
<td>
<input type="text" name="fare_<?=$slno?>" id="fare_<?=$slno?>" value="<?=$row->fare?>" readonly="true">
</td>
<td>
<?=$row->current_seat_available?> No(s).
</td>
<td>
<select name = "seat_required_<?=$slno?>" id="seat_required_<?=$slno?>" >
<? for($i=1; $i<=$row->current_seat_available; $i++ ) { ?>
<option value = "<?=$i?>"><?=$i?></option>
<? } ?>
</select>
</td>
</tr>
<? } ?>
<? $slno++; } ?>
<input type="hidden" name="total_schedule" id="total_schedule" value="<?=$slno?>">
</table>
这是控制器代码。
$ total_schedule = trim($ this-&gt; security-&gt; xss_clean($ _ POST ['total_schedule']));
for($x=0 ; $x<$total_schedule; $x++) {
if($_POST['slno_'.$x]) {
$schedule_time = $_POST['slno_'.$x];
$fare = $_POST['fare_'.$x];
$required_seat = $_POST['seat_required_'.$x];
}
}
请帮助。
答案 0 :(得分:0)
$('input[type="checkbox"]').click(function(){
var textValue = $('#textbox_id').val();
var dropdownValue = $('#dropdown_id').val();
// now make an ajax call to use this data
});