我有六个单选按钮,其id正在foreach循环中动态变化,现在我必须在foreach循环之外获取该值。如果有任何机构比解知道,请帮助。下面是我的代码
<div class="person_option-block">
<h5>No of Person</h5>
<?php
$no_of_persons = $this->Mdl_home->no_of_person_all();
foreach($no_of_persons as $no_of_person){ ?>
<label class="person_option">
<?php echo $no_of_person['person']; ?>
($ <?php echo $no_of_person['price']; ?>/person)
<input type="radio" class="person-radio" name="no_person" id="<?php echo $no_of_person['id']; ?>" value="<?php echo $no_of_person['id']; ?>"
onchange="get_makeup_service(<?php echo $no_of_person['person']; ?>)">
<input type="hidden" id="person_<?php echo $no_of_person['person']; ?>" value="<?php echo $no_of_person['person']; ?> ($<?php echo $no_of_person['price']; ?>/person)">
</label>
<?php } ?>
</div>
<div class="pull-right">
<a href="javascript:void(0);" class="custom-btn" id="step1-next-btn">
Next
<i class="fa fa-angle-double-right" aria-hidden="true"></i>
</a>
</div>
当我单击下一步按钮时,特定单选按钮的ID应发出警报
$('#step1-next-btn').click(function(){
$('#step1-block').hide();
$('#step2-block').show();
});
答案 0 :(得分:0)
使用$('input[name=no_person]:checked').val();
表达式获取选定的单选按钮值。
答案 1 :(得分:0)
尝试使用,
$(function(){
if($(“#radioID”)。prop(“ checked”)){
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'MyTable' AND COLUMN IS NOT EMPTY
}
});