我对这个程序有些问题。我想给模态使用语义ui但它不起作用。当我点击按钮顺序将显示模态但我的问题现在我点击按钮顺序显示新页面。并且无法插入数据库。
查看代码:
<div class = "ui form grid_6 omega">
<form target="paypal" method="post">
<div class="field1">
<div class="field">
<label>Nama</label>
<input placeholder="Nama" name="nama" type="text">
</div>
<div class="field">
<label>No. HP</label>
<input placeholder="No. HP" name="handphone" type="text">
</div>
<div class="field">
<label>Alamat</label>
<input placeholder="alamat" name="alamat" type="text">
</div>
<div class="field">
<label>Jumlah</label>
<div class="selectbox">
<select name="jumlah" id="">
<?php for ($i=1; $i <= 20; $i++): ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</div>
</div>
<button type="submit" class="ui teal button order-button">Order now</button>
</div>
</form>
</div>
<div class="ui small modal">
<i class="close icon"></i>
<div class="header">
Smalls Like Bakin
</div>
<div class="content">
<p>Thank you for your order</p>
</div>
<div class="actions">
<div class="ui positive right labeled icon button">
<a class="text-white" href="<?php echo site_url('home/order');?>">Back to Home</a>
<i class="checkmark icon"></i>
</div>
</div>
</div>
和脚本
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>packaged/javascript/semantic.js"></script>
<script type="text/javascript">
$('.order-button').click(function(){
$('.small.modal').modal('show');
});
</script>
控制器代码;
function simpanOrder()
{
$this->load->model("M_order");
$data['nama'] = $_POST['nama'];
$data['handphone'] = $_POST['handphone'];
$data['alamat'] = $_POST['alamat'];
$data['jumlah'] = $_POST['jumlah'];
$result = $this->M_order->insert($data);
}
你能告诉我我的代码问题在哪里以及如何解决它?谢谢。
答案 0 :(得分:0)
尝试给你的模态div一个id为:
<div id="modaldiv" class="ui small modal">
并在脚本中进行更改:
<script type="text/javascript">
$('.order-button').click(function(){
$('#modaldiv').modal('show');
});
</script>
另外请确保已包含所有必需的javasript文件以运行模式。