doufu8887 2016-08-22 23:41
浏览 18

我如何在CI中将其他值提交到我的数据库

Hi guys i would like to ask how i can submit in codigniter the other value from html select list to the same column in the data base , for example .

I have this code in Html :

<selectid="major"class="formcontrol"name="f4"onchange='CheckColors(this.value);' required >
<option value="other">other</option>
</select>
 <input type="text" name="f4" id="major" style='display:none;'/>

So when i click other another input show up (Javascript) ,

I need the value of the input field to be submit to data base to the same place , and not the value of the select :

And this is my model :

function insert_into_db()
 {

   $f1 = $_POST['f1'];
   $f2 = $_POST['f2'];
   $f3 = $_POST['f3'];
   $f4 = $_POST['f4'];
   $f5 = $_POST['f5'];
   $f6 = $_POST['f6'];
   $f7 = $_POST['f7'];
   $f8 = $_POST['f8'];
   $f9 = $_POST['f9'];




   $this->db->query("INSERT INTO end VALUES('','$f1','$f2','$f3','$f4','$f5','$f6','$f7','$f8','$f9')");
 }

the value f4 , i need to be submit from the select list if its selected , other wise it will be submitted from the input value , please any help ?

  • 写回答

2条回答 默认 最新

  • doufud21086 2016-08-23 00:35
    关注

    It's not recommended to use duplicated name for two separate form elements.

    Try to use different name for the select box and the input box. You can still compare the posted values on server and then pick one for storing.

    You may have a complicated UI but try not to make the form fields complicated too.

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值