0

In my Jsp the value and class is generating dynamically in a loop.

<div>
    <c:forEach var="interestTab" varStatus="loop" items="${interestParam}">
        <c:set var="interestFields" value="${fn:split(interestTab, '|')}" />
        <c:set var="maxAmt" value="${interestFields[1]}" scope="page" />
        <c:set var="minAmt" value="${interestFields[0]}" scope="page" />
        <c:set var="interestRate" value="${interestFields[2]}" scope="page" />
        <div class="personalcal-${loop.index}" style="display:hidden;">
            <div class="minamount-${loop.index}">
                ${interestFields[0]}
            </div>
            <div class= "maxamount-${loop.index}">
                ${interestFields[1]}
            </div>
            <div class= "intrate-${loop.index}">
                ${interestFields[2]}
            </div>
        </div>
    </c:forEach>

</div>

i want to get all the values in jquery how can i do it ?? if it was not dynamically generated class or id then i can get it simply through $(".class").text(). but now my class is changing with loop how can i get it ??

2
  • i didn't get your problem , will you explain more Commented Nov 6, 2013 at 7:20
  • In my requirement the i want to get the values ${interestFields[0]} ,${interestFields[1]},${interestFields[2]} in my jquery file. if its class is not dynamically generated then i can get it through this $('.minamount').text(). but now the class is changing everytime then how can i get it ?? Commented Nov 6, 2013 at 7:24

1 Answer 1

1
put the below line in your jsp
<input type='hidden' value='${fn:length(interestParam)}' id="interestParamCount"/>

here is how to iterate in your js file

  for(counter = 0 ; counter < $('#interestParamCount').val();counter++){
      alert($('.minamount-'+counter).text());
      alert($('minamount-'+counter).text());
      alert($('intrate-'+counter).text());
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.