title: comparing values on keyup of textbox Struts 2 java script validation
body: <p>I am using Struts 2 java web app.and newbie in javascript. In  the jsp page the scenario is like this</p>
  
  <pre><code>&lt;s:iterator value="objlist" status="status"&gt;
  &lt;s:property  value="qty1"/&gt;
  &lt;s:property  value="qty2"/&gt;
  &lt;s:textfield name="qty3" id="%{id1}"  onkeyup="check()" required="true"/&gt;
  &lt;/s:iterator&gt;
  </code></pre>
  
  <p>script method</p>
  
  <pre><code>function check() {
                  var qty1=(document.getElementsByName('qty1')[0].value);
                  var qty2=(document.getElementsByName('qty2')[0].value);
                  var qtytextbox=(document.getElementsByName('qty3')[0].value);
                  comparing part{
                  }
  }
  </code></pre>
  
  <p>Consider arraylist has 3 rows.
  In the script, I need to subtract qty1 and qty2 and the result should be lesser than the entered text box value of the particular row. For that I have to get the property value of qty1 and qty2 in my javascript method which i failed to get.I cant read struts property value inside javascript. I tried declaring a <code>&lt;s:hidden&gt;</code> inside the iterator and when its called inside the script, I get the value of first row only. how can we compare the  textbox value with the  corresponding row values? how can we get the struts property value inside the javascript method?</p>