Hello every body
Iam a newbie
Iam using struts1 and i have a ploblem want to ask you
When i use a script to automate add two numbers from 2 textfield, i use a script and code like this and it work properly
Num1 : <html:text property="num1" onkeyup="calc()" value=""/>
<br>
Num2 : <html:text property="num2" onkeyup="calc()" value=""/>
<br>
Num3 : <html:text property="num3" value=""/>
But if i want to do this in many lines, i use a loop by logic:iterate tag:
<logic:iterate id="listUser" name="UserActionForm" property="listUser">
Num1 : <html:text name="listUser" property="num1" value="${listUser.num1}"
indexed="true" onkeyup="calc()"/>
Num2 : <html:text name = "listUser" property="num2" value="${listUser.num2}"
indexed="true" onkeyup="calc()"/>
Num3 : <html:text name="listUser" property="num3" indexed="true"/>
<br>
</logic:iterate>
and it doesn't work
sorry, this is my script
<script type="text/javascript">
function calc()
{
var num1 = document.forms[0].num1.value;
var num2 = document.forms[0].num2.value;
if(num1 != "" && num1.length!= 0 && num2!="" && num2.length != 0){
var num11 = parseInt(num1);
var num22 = parseInt(num2);
document.forms[0].num3.value = num11*num22;
} else{
document.forms[0].num3.value = "";
}
}
</script>
so, can you show my mistakes and how to fix them
Thanks so much