0
<script type="text/JavaScript">
    $(document).ready(function(){ 
        $("#selecctall").change(function(){
                 <% int j =0; %>
                 var current = 0;
            $.each($("input[name='deferral']"),function(){
               if($('#deferral'+current).is(':checked')){
                current++;
                 <% j ++; %>
                alert(<%= j %>);
               }else{
                $('#deferral'+current).prop('checked', true);
               <%if(j< rowid.size()){%> 
                function($(this).val(),'<%= (String)vendor.get(j)%>','<%= (String)invoice.get(j)%>', current)
               alert(<%= j %>);
               <%}%>
                current++;
                  <% j ++; %>
                }
            });  
        });  
    });                                 
</script>

In above code I tried to increase the value of 'j' but it is not increasing.

otherwise I want to "(String)vendor.get(j)" this function should accept JavaScript variable i.e. 'current',but how can I convert 'current' JavaScript variable into java integer

1
  • 1
    Java: server. JavaScript: client (in this case). This is a mish-mosh of concerns; please consider a different approach that's easier to read, maintain, and think about. Commented Jun 3, 2016 at 11:31

1 Answer 1

1

you cannot put java coding inside javascript can yos add a more information about j where is j is coming from the i will help you
this would be some thing like this firs you have to get the value of j then increment it

<script type="text/JavaScript">
$(document).ready(function(){ 
    $("#selecctall").change(function(){
             var j=$('#from some where').val();// you have to get the value of j from somewhere 
j++;//them increment it
             var current = 0;
        $.each($("input[name='deferral']"),function(){
           if($('#deferral'+current).is(':checked')){
            current++;
             <% j ++; %>
            alert(<%= j %>);
           }else{
            $('#deferral'+current).prop('checked', true);
           <%if(j< rowid.size()){%> 
            function($(this).val(),'<%= (String)vendor.get(j)%>','<%=   (String)invoice.get(j)%>', current)
           alert(<%= j %>);
           <%}%>
            current++;
              <% j ++; %>
            }
        });  
    });  
});                                 
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

I already have 'current' JavaScript variable, how can assign or use JavaScript variable value in java
see javascript and java are two diffrent thing we cant mix there codings meant to say we cant write java coading(<%some code %>) in side <script></script> tag

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.