How to pass an array as a value of hidden varialble ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akshay01
    New Member
    • May 2008
    • 12

    How to pass an array as a value of hidden varialble ??

    Hi All,
    I am using the following code in which i am creating some textboxes and and as the for loop continues the name of the textboxes will also be unique for all the textboxes.
    now i want to store the textbox values into some array and want to pass the array as an value of hidden variable

    Code:
    <% 
    int i =0;
    
    String[] arr_TextValues = new String[10];
    String[] arr_ChkValues = new String[10];
    String[] TextVal = new String[10];
    for (i=0; i<user_ArrLen; i++ ) 
    {
    
        arr_TextValues[i] = "Text"+i;
        arr_ChkValues[i] = "Chk"+i; 
       TextVal[i] = "hidden"+i;			      
      %>
     			 
     <td><input type=text name=<%=arr_TextValues[i]%> value=""/>
    <td><input type="checkbox" name=<%=arr_ChkValues[i]%> VALUE="0" align ="center" ></td> 
    <td><input type=hidden name=<%=TextVal value[i]%>value="0"></td>
    		          
    <%
    }
    
    %>
    I am using the following js in my Jsp to retrieve the value of hidden variable .. but it is not working :( it is giving me the error like hidden variable value is null .

    Code:
      <script language=javascript>
        
        function check()
        
        { 
       
               no_of_row = document.form1.dev.value 
               
               names_array = new Array(no_of_row);
              
               for(l=0;l<no_of_row;l++)
               
              {
               
               var txt="Text"+l; 
               var chk="Chk"+l; 
               var hid="Hid"+l;      
         
    
          if(document.form1.elements[chk].checked)
           	{
           	 
           	names_array[l]= document.form1.elenents[hid].value;
           	 
           	var v = document.form1.elements[txt].value;
           	  
           	 
            alert(names_array[l]);
            
            //form1.submit();
        	
        	//return true;
            
    	  
    	       	
           	}
           	
           	else
           	
           	{
           	
           	
     
              alert('Please check the assign token');
           		return false;
           	} 
        
          }
         
        } 
        
      
      </script>
    any help will be appriciated.
    Thanks !
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    First of all, there's a problem in your jsp.
    Look at line 12 and line 17.

    Secondly, you asked question related to the same issue five days ago. And you didn't tell me if the solution I gave worked or not. So how could I further work on solving your problem?

    Comment

    • akshay01
      New Member
      • May 2008
      • 12

      #3
      Sorry for not replying you hsriat !! your solution was fine and i implemented the same.. and it is working fine .
      By mistake i have posted the wrong code ..
      the line 12 and 17 are as;
      Code:
      arr_TextVal[i]  = "Hid"+i;
      
      <td><input type=hidden name=<%=arr_TextVal[i]%> value=""></td>
      Thanks for your reply !
      sorry once again

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        No need of sorry dude :)

        Just wanted to make sure you have not missed that post by mistake.

        One more, line 23: Its elements, not elenents.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by akshay01
          Sorry for not replying you hsriat !! your solution was fine and i implemented the same.. and it is working fine .
          If it wasn't asked, we'd never have known. It's common courtesy to let people know if a suggestion was helpful or answered your question. See Once your question has been answered.

          Comment

          Working...