我有两个输入项
<td> <input type="number" id="primaryincome2" min="1" max="999" name="noc[]"
value="<?php echo (!isset($student2['noc'])) ? 0 : $student2['noc'] ?>"
disabled> </td>
<td> <input type="text" > </td>
基于第一项,该值将被张贴在第二项中。需要建议。
答案 0 :(得分:0)
<td><input type="number" id="primaryincome2" min="1" max="999" name="noc[]"
value="<?php echo (!isset($student2['noc'])) ? 0 : $student2['noc'] ?>"
> </td>
<td> <input type="text" id="eprimaryincome2"> </td>
<script>
$("#primaryincome2").on("keyup click",function(){
$("#eprimaryincome2").val($(this).val());
})
</script>
尝试此操作,您可以同时在鼠标和键盘事件中使用。
答案 1 :(得分:-1)
如果准备使用jquery,则可以使用此代码,
<td> <input onkeyup="$('#eprimaryincome2').val(this.value)" type="number" id="primaryincome2" min="1" max="999" name="noc[]"
value="<?php echo (!isset($student2['noc'])) ? 0 : $student2['noc'] ?>"
disabled> </td>
<td> <input type="text" id="eprimaryincome2" > </td>