id
如何进入我的模态进行编辑?我正在使用php并且必须使用对话框模式更新数据。我怎样才能做到这一点?
<a href="" data-toggle="modal" data-target="#myLargeModal">
<?=$objResult["ID"]; ?>
<div class="modal fade" id="myLargeModal" tabindex="-1" role="dialog"
aria-hidden="true">
<input type="text" class="form-control required" name="ID" id="ID"
minlength="5" required/>
<input type="text" class="form-control required" name="Name"
id="Name" required>
</div>
答案 0 :(得分:0)
<a href="" data-toggle="modal" id="modalIdOpen" data-id="<?php echo $objResult["ID"]; ?>" data-target="#myLargeModal">Open Modal</a>
<div class="modal fade" id="myLargeModal" tabindex="-1" role="dialog"
aria-hidden="true">
<input type="text" class="form-control required" name="ID" id="ID"
minlength="5" required/>
<input type="text" class="form-control required" name="Name"
id="Name" required>
</div>
必要的jquery脚本
<script>
$(function() {
$(document).on('click','#modalIdOpen',function(e){
//process here you can get id using
$('#ID').val($(this).data('id')); //and set this id to any hidden field in modal
});
});
</script>
答案 1 :(得分:0)
you can put the id in a filed value directly
<a href="" data-toggle="modal" data-target="#myLargeModal"> open it </a>
<div class="modal fade" id="myLargeModal" tabindex="-1" role="dialog"aria-hidden="true">
<input type="text" name="ID" value="<?=$objResult["ID"]; ?>" />
<input type="text" class="form-control required" name="Name"
id="Name" required>
</div>