0
<?php 

$options = array(
                  500  => 500,
                  1000 => 1000,
                  2500 => 2500,
                  5000 => 5000,
                );

echo form_dropdown('units',$options);

?>

$db_num = 25; # a random number
$post_num = $set_num * (units-selected) 

单击提交时,如何将单位下拉列表的选定值与我的值相乘$db_num?我认为这可能需要javascript,但没有可能吗?

在我的控制器上,我尝试了这个:

$db_num = $this->input->post('db_num');
$units = $this->input->post('units');

$answer = $db_num * $units;

...

echo $answer; 

(结果没有错误也没有插入。我做错了什么?)

4

3 回答 3

0

使用php implode函数存储和explode函数显示

$itm= $_POST['hospital_department']; $comma_separated = implode("-", $itm);

$data['hospital_department']            = $comma_separated;
于 2012-10-08T11:11:33.007 回答
0

需要将传递我的变量的数据库字段设置为INT- 问题已解决。

于 2012-10-05T00:39:45.713 回答
0

就像是 :

<form ... onsubmit="return functionwhereyouwilldothemath(this)" >
</form>

<script type="text/javascript">
function functionwhereyouwilldothemath(el) { //el = javascript form object
    var db_num = <?=$db_num?>; //yup this is legit.
     //do your math
    return true; //will cause the page to reload uppon submit.
}
</script>
于 2012-10-05T00:19:24.903 回答