how to get random value in struts set tag

Hariprasath

Im using struts2 tags for my application. I need to change the value randomly from script to s:set tag and populate into the javascript array. If i add dynamically means i get the output as 2012 - diff + 1 but my expected output as 2011 . How can i achieve this, my code is

var threeDatas = [];
var prevyear = [];
var diff;
var flagthree = false;

<% int j = 0;%>

<s:iterator value="testlist">
    prevyear.push(<s:property value="year"/>);
    if (<%= j - 1%> !== -1) {
        if (prevyear[<%= j - 1%>] !== prevyear[<%= j%>] - 1) {
            diff = prevyear[<%= j%>] - prevyear[<%= j - 1%>];
        }
        if (diff > 1) {                                                   
            for (inc = 1; inc < diff; inc++) {
                <s:set var="incyear"> <s:property value="year"/> - diff+1</s:set>
                 threeDatas.push(['<s:property value="#incyear"/>', null, null]);
            }
            flagthree = true;
            diff = 0;
        }

<% j++;%>

</s:iterator>

i need my final array value should be link

['x', 'Cats','Dogs'],
     ['2008',   10, null],
     ['2009',   20, null],
     ['2010',   null, null],
     ['2011',   null, 23],
     ['2012',   null, 34]
James Jithin

You can use the eval() method in JavaScript. So, if you can generate something like

var incyear = eval('<s:property value="year"/> - diff + 1');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to dynamically set the "value" attribute of url tag in struts2?

From Dev

How struts property tag works with date value?

From Dev

How struts property tag works with date value?

From Dev

How to get checked value of checkbox in Struts 2 tag <s:checkbox> into action class

From Dev

How to inject the value of a Struts <s:property /> tag into another tag

From Dev

How to get and set value to html tag using array in javascript?

From Dev

How to insert a value into Set collection in Struts 2

From Dev

How to insert a value into Set collection in Struts 2

From Dev

How to get value of child tag of a button tag

From Dev

Struts 2 <s:if> tag How to get action name to be evaluated in jsp

From Dev

how to get the tag value in XSLT

From Dev

how to get second tag value

From Dev

How to set a variable to a random value with bash

From Dev

How to get a random element from a Set in Scala

From Dev

How to get random element from a set in Swift?

From Dev

How to get the text from a random set textview?

From Dev

How to set a value in application scope in struts2?

From Dev

How to set s:param value in Ajax success body in Struts 2

From Dev

How can set a default value in select tag?

From Dev

How to set value of an input tag in casperJs

From Dev

How to set PHP tag $value into a Javascript parameter?

From Dev

how to set value in javascript div tag

From Dev

in Node.js, how to get set-cookie value in a <meta http-equiv> tag

From Dev

How to set and get tag in xaml dynamically?

From Dev

How to use Struts url tag in iterator tag

From Dev

How to get random value from an array?

From Dev

How to get a random number with a minimum value

From Dev

How to get value from json with random ID

From Dev

How can I get a tag in a view and set some InnerHtml to this tag?

Related Related

  1. 1

    how to dynamically set the "value" attribute of url tag in struts2?

  2. 2

    How struts property tag works with date value?

  3. 3

    How struts property tag works with date value?

  4. 4

    How to get checked value of checkbox in Struts 2 tag <s:checkbox> into action class

  5. 5

    How to inject the value of a Struts <s:property /> tag into another tag

  6. 6

    How to get and set value to html tag using array in javascript?

  7. 7

    How to insert a value into Set collection in Struts 2

  8. 8

    How to insert a value into Set collection in Struts 2

  9. 9

    How to get value of child tag of a button tag

  10. 10

    Struts 2 <s:if> tag How to get action name to be evaluated in jsp

  11. 11

    how to get the tag value in XSLT

  12. 12

    how to get second tag value

  13. 13

    How to set a variable to a random value with bash

  14. 14

    How to get a random element from a Set in Scala

  15. 15

    How to get random element from a set in Swift?

  16. 16

    How to get the text from a random set textview?

  17. 17

    How to set a value in application scope in struts2?

  18. 18

    How to set s:param value in Ajax success body in Struts 2

  19. 19

    How can set a default value in select tag?

  20. 20

    How to set value of an input tag in casperJs

  21. 21

    How to set PHP tag $value into a Javascript parameter?

  22. 22

    how to set value in javascript div tag

  23. 23

    in Node.js, how to get set-cookie value in a <meta http-equiv> tag

  24. 24

    How to set and get tag in xaml dynamically?

  25. 25

    How to use Struts url tag in iterator tag

  26. 26

    How to get random value from an array?

  27. 27

    How to get a random number with a minimum value

  28. 28

    How to get value from json with random ID

  29. 29

    How can I get a tag in a view and set some InnerHtml to this tag?

HotTag

Archive