我正在创建一个表单以将记录插入我的数据库,并且我正在尝试在其中创建一个下拉按钮。
这是我的表格代码:-------------------------------------
<form action="<?php echo site_url('Product/product_form'); ?>" method="post">
<table class="calendar_table">
<tr>
<td><?php echo form_input(array('id'=>'product_naam', 'name'=>'product_naam', 'placeholder' => '1. Naam van het cadeau', 'size'=>25));?></td>
</tr>
<tr>
<td><?php echo form_input(array('id'=>'product_categorie', 'name'=>'product_categorie', 'placeholder' => 'Kies een categorie', 'size'=>25));?></td>
</tr>
<tr>
<td><?php echo form_input(array('id'=>'ophaal_plaats', 'name'=>'ophaal_plaats', 'placeholder' => '3.Kies een stad', 'size'=>25));?></td>
</tr>
<tr>
<td>
<?php echo form_input(array('id'=>'product_foto', 'name'=>'product_foto', 'placeholder' => '4. Upload foto', 'size'=>25));?></td>
</tr>
<tr>
<td><?php echo form_input(array('type'=>'textarea','id'=>'product_beschrijving', 'name'=>'product_beschrijving', 'placeholder' => '5. Vertel iets over dit cadeau', 'size'=>25));?></td>
</tr>
<tr>
<td></td>
<td><button type="submit" class="btn btn-primary">Cadeau aanbieden!</button>
</td>
</tr>
</table>
</form>
这是我想用下拉按钮替换的输入类型字段:
<td><?php echo form_input(array('id'=>'product_categorie', 'name'=>'product_categorie', 'placeholder' => 'Kies een categorie', 'size'=>25));?></td>
有人可以帮我吗? 感谢
答案 0 :(得分:0)
似乎一个简单的谷歌搜索提供了很多结果,例如:https://www.formget.com/codeigniter-form-dropdown/
$options = array(
'Computer Science Engineering' => 'Computer Science Engineering',
'Electronics and Comm. Engineering' => 'Electronics and Comm. Engineering',
'Mechanical Engineering' => 'Mechanical Engineering',
'Civil Engineering' => 'Civil Engineering',
);
echo form_dropdown('Department', $options, 'Computer Science Engineering', 'class="dropdown_box1"');
答案 1 :(得分:0)
为什么不从一些HTML基础知识开始呢? W3Schools
<?php
$selectField = "
<select name="mySelectField">
<option value="xxxx">discription1</option>
<option value="yyyy">discription2</option>
</select>
";
// wherever needed
echo($selectField);
?>