第二选择选项没有获得价值

时间:2018-05-22 17:48:00

标签: php

请检查我的第二个选择框获取值,但不能从第一个选择框中获取值。请检查我的代码我错了吗?

这是我的代码:

Area

请检查我错在哪里。在此先感谢:)

1 个答案:

答案 0 :(得分:3)

<select class='form-control' id=class_code name=class_code onchange='setTextField1(this)'>
    <option value=''>Select class</option>";
    <option value=$row[class_code]>$row[class]</option>";
</select>
<input id='cls' type = 'hidden' name = 'cls' value = '' />
<script type='text/javascript'>
    function setTextField1(dddl) {
        document.getElementById('cls').value = dddl.options[dddl.selectedIndex].text;
    }   
</script>

<select class='form-control' id=semester_id name=semester_id onchange='setTextField(this)'>
    <option value=''>Select semester</option>
    <option value='1'>semester1</option>
</select>
<input id='semm' type = 'hidden' name = 'semm' value = '' />
<script type='text/javascript'>
    function setTextField(ddl) {
          document.getElementById('semm').value = ddl.options[ddl.selectedIndex].text;
    }
</script>