473,657 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

12 New Member
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 2369
hsriat
1,654 Recognized Expert Top Contributor
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
akshay01
12 New Member
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 Recognized Expert Top Contributor
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 Recognized Expert Moderator MVP
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
6781
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 stuck: I have page of results obtained from a MySQL query presented as a table (the first column having checkboxes for each of the rows in the table, and all having the name "seqs"). I have set up a javascript (connected to a "toggle all" checkbox)...
4
5384
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 product the visitor can order by clicking one or more checkboxes. I made a form containing input with type "checkbox" like: <form> <input type="checkbox" name=ck id=ck
4
1781
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. thanks!! ============================================ void reverse(char s); void count(int x);
10
69936
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
3396
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
248143
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 this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
4
4333
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 "selectedValues" from next page for php variable this is my javascript code saved on "sendValue.js" file, <script> function updateRecordEntry(requestValue){
9
2548
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 this line: $result = $_POST; I need the $result on the clm_historyXL page to print a list to excel because of a header already being sent.
9
30103
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 and I can't get this issue out of my head !!!! So I'm obviously missing something really simple and can't see it or it can't be done with my limited knowledge. I know that I can use a cookie to store the array as string - I have this working but...
0
8303
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.