本文介绍了用另一个输入字段值更新隐藏的输入字段值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更新一个隐藏的输入字段与另一个可见的输入字段使用JavaScript ...

但我的代码不起作用的一些原因!!



这是我的javascript:

 < script language =javascript > 
function process1(){
document.getElementById(sum_total)。value =(document.getElementById(my-item-price)。value);
}
< / script>

这是我的表单代码:

 < form>< input name =A1type =textclass =A1id =A1/>< / form> 

< form>< input type =hiddenid =A2name =A2value =process1()/>< / form>

更新

 < script language =javascript> 
function process1(){
document.getElementById(sum_total)。value =(document.getElementById(my-item-price)。value);
}
< / script>


解决方案

您拥有的代码很糟糕。你还没有找到 id 你在javascript中寻找。



试试这个:

 < script language =javascript> 
函数process1(显示){
document.getElementById(A2)。value = displayed.value;
}
< / script>

< form>< input name =A1type =textclass =A1onChange =process1(this)/>< / form>

< form>< input type =hiddenid =A2name =A2value =5/>< / form>


I am trying to update one hidden input field with another visible input field using javascript...

but my code doesn't work for some reason!!

This is my javascript:

<script language="javascript">
    function process1() {
        document.getElementById("sum_total").value = (document.getElementById("my-item-price").value);
    }
</script>

And This Is My form code:

<form><input name="A1" type="text" class="A1" id="A1"/></form>

<form><input type="hidden" id="A2" name="A2" value="process1() "/></form>

Update

<script language="javascript"> 
    function process1() { 
        document.getElementById("sum_total").value = (document.getElementById("my-item-price").value); 
    } 
</script>
解决方案

The code you have is bad. You haven´t got ids you are looking for in javascript.

Try this:

 <script language="javascript">
 function process1(showed) {
    document.getElementById("A2").value = showed.value;
}
</script>

<form><input name="A1" type="text" class="A1" onChange="process1(this)"/></form>

<form><input type="hidden" id="A2" name="A2" value="5" /></form>

这篇关于用另一个输入字段值更新隐藏的输入字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 09:16