开发者

Copying value from one textbox to another textbox in a particular row

开发者 https://www.devze.com 2023-03-04 12:55 出处:网络
<input type="text" class="formtext" id ="t${status.index}" name="List.lItemList<c:out value=\'[${status.index}]\'/>.value1" value="0.0"
<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')">

In the above code I have two text boxes in a particular row:

1st row textbox1 textbox2

2nd row textbox3 textbox4

When I enter the value in one of the textbox, it needs to be copied to other textbox simultaneously. So I am using an onKeyUp event to update the textbox, but the ID开发者_如何学运维 for each textbox is giving issues. Regardless of which textbox I update only textbox2 is updated. I want it to be updated based on the row.

Example:

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


You need to add to the ID something that identify the row.


How about

<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')">
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号