我有這種形式,可以讓你選擇或添加一個選項到下拉字段,問題是當你點擊添加選項,它調用模式,但它也提交了整個表單,但我把在輸入欄上所需的標記,以便它並沒有真正傳遞的形式,除非完成窗體和引導模式
這裏的形式:
<div class="col-lg-12">
<form action="<?php echo base_url(); ?>products/purchase" role="form" accept-charset="utf-8" method="post">
<div class="form-group">
<div class="col-lg-12">
<label class="control-label">Name</label>
<input type="text" name="name" class="form-control inline" required>
</div>
</div>
<div class="form-group">
<div class="col-lg-10">
<label class="control-label">Class</label>
<div class="input-group">
<select name="class_ID" class="form-control" required>
<option value="">Select Class</option>
<?php if(!empty($cls)){
if (is_array($cls)){
foreach ($cls as $row) {?>
<option value="<?php echo $row['class_id']?>"><?php echo $row['class_Name']; ?></option>
<?php }
}
}
else{ ?>
<option value=""></option>
<?php }?>
</select>
<span class="input-group-btn">
<button class="btn btn-theme" data-toggle="modal" data-target="#addClass"><i class="fa fa-plus"></i></button>
</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-12 pull-right">
<input type="submit" class="btn btn-success pull-right" value="Order" style="margin-left:5px;">
</form>
<a href="<?php echo base_url()?>purchases" class="btn btn-default pull-right">Back</a>
</div>
</div>
</div>
和模態:
<div class="modal fade" id="addClass" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="vertical-alignment-helper">
<div class="modal-dialog vertical-align-center">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Add New Product Classification</h4>
</div>
<div class="modal-body">
<form action="<?php echo base_url(); ?>products/add_class" method="post" accept-charset="utf-8" role="form">
<div class="form-group">
<div class="col-lg-6">
<label for="class_Name">Classification Name</label>
<input type="text" name="class_Name" class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-lg-3">
<label for="is_active">Enabled</label>
<select name="is_active" class="form-control">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" class="btn btn-success" value="ADD">
</form>
</div>
</div>
</div>
</div>
</div>
我的表格頁面自然採取行動,因爲每當我點擊按鈕data-target = #addClass它也會觸發表單action =「<?php echo base_url(); ?>產品/購買「 – NaDie
是的我知道了,你可以將'
或者你可以告訴'