양식에 라디오 버튼이 있습니다. 참조 번호를 입력하면 소스 값과 함께 해당 양식 세부 정보를 가져올 수 있습니다. jQuery을 사용합니다. 그 값을 라디오 버튼으로 설정하는 방법을 모르겠습니다. 고맙습니다!jQuery를 사용하여 편집하는 동안 라디오 버튼의 값을 설정하는 방법은 무엇입니까?
<input type="radio" ng-model="selected" name="source" class="source" <?php echo ($row['source']=='VAT')?'checked':'' ?> value="VAT">VAT
<input type="radio" ng-model="selected" name="source" class="source" <?php echo ($row['source']=='CST')?'checked':'' ?> value="CST">CST
jQuery를
$('#gp_no').on('keypress', function(e){
if(e.keyCode === 13)
{
$(this).trigger("enterKey");
var val = $(this).val();
var dataString = "gp_no=" + val;
$.ajax({
type: "POST",
url: "post_process.php",
data: dataString,
dataType: 'json',
success: function(data){
$('.source').val(data.source);
}
});
}
});
post_process.php
if(ISSET($_POST['gp_no'])) {
$gp_no = $con->real_escape_string($_POST['gp_no']);
$query = "SELECT * FROM items WHERE items.gp_no = $gp_no";
if ($result = $con->query($query)) {
$row = $result->fetch_assoc();
$source = $row['source'];
}
$json = array($vehicle_no, 'source' => $source);
$json = json_encode($json);
echo $json;
}
CST
당신이 하나 개의 라디오 버튼이 있습니까 않습니다 assune? – FrancoID가 될 수없는 것은 고유해야합니다 – Franco
@Franco 두 개의 라디오 버튼이 있습니다. 질문을 업데이트했습니다. – Naresh