473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1. <% 
  2. int i =0;
  3.  
  4. String[] arr_TextValues = new String[10];
  5. String[] arr_ChkValues = new String[10];
  6. String[] TextVal = new String[10];
  7. for (i=0; i<user_ArrLen; i++ ) 
  8. {
  9.  
  10.     arr_TextValues[i] = "Text"+i;
  11.     arr_ChkValues[i] = "Chk"+i; 
  12.    TextVal[i] = "hidden"+i;                  
  13.   %>
  14.  
  15.  <td><input type=text name=<%=arr_TextValues[i]%> value=""/>
  16. <td><input type="checkbox" name=<%=arr_ChkValues[i]%> VALUE="0" align ="center" ></td> 
  17. <td><input type=hidden name=<%=TextVal value[i]%>value="0"></td>
  18.  
  19. <%
  20. }
  21.  
  22. %>
  23.  
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 .

Expand|Select|Wrap|Line Numbers
  1.   <script language=javascript>
  2.  
  3.     function check()
  4.  
  5.     { 
  6.  
  7.            no_of_row = document.form1.dev.value 
  8.  
  9.            names_array = new Array(no_of_row);
  10.  
  11.            for(l=0;l<no_of_row;l++)
  12.  
  13.           {
  14.  
  15.            var txt="Text"+l; 
  16.            var chk="Chk"+l; 
  17.            var hid="Hid"+l;      
  18.  
  19.  
  20.       if(document.form1.elements[chk].checked)
  21.            {
  22.  
  23.            names_array[l]= document.form1.elenents[hid].value;
  24.  
  25.            var v = document.form1.elements[txt].value;
  26.  
  27.  
  28.         alert(names_array[l]);
  29.  
  30.         //form1.submit();
  31.  
  32.         //return true;
  33.  
  34.  
  35.  
  36.            }
  37.  
  38.            else
  39.  
  40.            {
  41.  
  42.  
  43.  
  44.           alert('Please check the assign token');
  45.                return false;
  46.            } 
  47.  
  48.       }
  49.  
  50.     } 
  51.  
  52.  
  53.   </script>
  54.  
any help will be appriciated.
Thanks !
May 27 '08 #1
4 2356
hsriat
1,654 Expert 1GB
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?
May 27 '08 #2
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;
Expand|Select|Wrap|Line Numbers
  1.  
  2. arr_TextVal[i]  = "Hid"+i;
  3.  
  4. <td><input type=hidden name=<%=arr_TextVal[i]%> value=""></td>
  5.  
  6.  
Thanks for your reply !
sorry once again
May 27 '08 #3
hsriat
1,654 Expert 1GB
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.
May 27 '08 #4
acoder
16,027 Expert Mod 8TB
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.
May 27 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nath | last post by:
Please help!? I am new to writing html, javascript, pretty new to MySQL but quite proficient at writing Perl and i'm a quick learner. I am building a database driven website and i am a little...
4
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of...
4
by: jrefactors | last post by:
In the following program, are parameters s in function reverse() and x in function count() both pass by value? How come value k is not changed, but value str has changed? Please advise....
10
by: Jim | last post by:
What is the syntax for summing the elements of the an array and putting that value into another varialble? Please.
2
by: windsorben | last post by:
How would I pass the student's final score to a hidden form field? <script language="javascript" type="text/javascript"> <!-- var score = 0;
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
9
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on...
9
by: nicnac | last post by:
Hi, I'm self learning javascript - so any pointers are welcomed!! I have an issue passing a form and array from one function to another. I tried many variations ! I can't get this to work...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.