【问题标题】:copying value from one textbox to another textbox in a particular row将值从一个文本框复制到特定行中的另一个文本框
【发布时间】:2011-05-07 05:26:36
【问题描述】:
<input type="text" class="formtext" id ="t${status.index}"      
name="List.lItemList<c:out value='[${status.index}]'/>.value1" value="0.0"
onChange="validateOnChange(this,'desc','minvalue','maxValue','float')"
onKeyUp="document.getElementById('t${status.index+1}').value=this.value"> 

<input type="text" class="formtext" id ="t${status.index+1}"              
name="List.clItemList<c:out value='[${status.index}]'/>.value2" value="0.0"
onChange="validateOnChange(this,'desc','minvalue','maxvalue','float')">

嗨,在上面的代码中,我在特定行中有两个文本框

 1st row textbox1 textbox2  
 2nd row textbox3 textbox4 

当我在其中一个文本框中输入值时,它需要同时复制到其他文本框。所以我使用 onKeyUp 事件来更新文本框。但是每个文本框的 ID 都会给出问题。不管哪个文本框我只更新了 textbox2。我希望它根据行更新。谢谢

Ex =
For each {
    Input type(id = status.index onkeyup)
    input type(id = status.index+1 update the value entered on the 1st textbox )
} repeat

【问题讨论】:

  • 看不懂是怎么回事,能否加个示例代码或者加更清晰的信息?

标签: javascript javascript-events


【解决方案1】:

您需要在 ID 中添加一些标识行的内容。

【讨论】:

    【解决方案2】:

    怎么样

    <input type="text" class="formtext" id ="t${status.index}"      
    name="List.lItemList<c:out value='[${status.index}]'/>.value1" value="0.0"
    onChange="validateOnChange(this,'desc','minvalue','maxValue','float')"
    onKeyUp="this.form[this.name.replace('value1','value2')].value=this.value"> 
    
    <input type="text" class="formtext" id ="t${status.index+1}"              
    name="List.clItemList<c:out value='[${status.index}]'/>.value2" value="0.0"
    onChange="validateOnChange(this,'desc','minvalue','maxvalue','float')">
    

    【讨论】:

      猜你喜欢
      • 2020-04-05
      • 1970-01-01
      • 1970-01-01
      • 2014-06-09
      • 1970-01-01
      • 1970-01-01
      • 2020-01-22
      • 1970-01-01
      • 2011-08-19
      相关资源
      最近更新 更多