value not being stored in the array variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hariomt
    New Member
    • Jan 2009
    • 10

    #1

    value not being stored in the array variable

    Hi,
    I am using a global variable qArray in js file.I have include this file in a jsp file.
    Now I am using a list<String> to populate the qArray.
    On click of a button on the jsp page I want to access the qArray but i am not able to do so.
    below is the code snippet:

    Code:
    // in abc.js
    qArray=new Array();
    function removeProducts(){
        alert(quoteProductsArray[0]);
    }
    // in abcd.jsp
    <script>
                <%
            for(int i=0;i<qProducts.size();i++)
            {
                        %>
               
                    qArray[<%=i%>]='<%=qProducts.get(i)%>'
           <%
            }
            %> 
              
            </script>
    
     <input  align="right" type="button" value="Update Products" name="RemoveProducts" onclick="removeProducts()"/>
    please help me out
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You're not trying to access qArray, you're accessing quoteProductArr ay[0]. Check the error console.

    Comment

    • hariomt
      New Member
      • Jan 2009
      • 10

      #3
      my mistake in writing the sample code here...
      the function is

      function removeProducts( ){
      alert(qArray);
      }

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Can you post the generated code instead (when you view the source in the browser)?

        Comment

        Working...