473,386 Members | 1,699 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,386 software developers and data experts.

How to pass an HTML array to another form

Hi there,

I am trying to pass an HTML element, which is an array, to another form. Not so difficult, I'd say, but I tried almost all possible combinations, and it doesn't work.

I have a form where I have this SELECT element:
Expand|Select|Wrap|Line Numbers
  1. <select name="preselectedCountries[]" size="9" multiple="multiple">
  2.   <option value="Albania">Albania</option>
  3.   <option value="Algeria">Algeria</option>

And I have another form:
Expand|Select|Wrap|Line Numbers
  1. <form method="post" name="formGeneric" action="">
  2.   <input type='hidden' name='preselectedCountries[]' value='' />
  3.  

Now, I'd like to hand over the selection from the first form to the second. Tried it in various forms like:

Expand|Select|Wrap|Line Numbers
  1. <a href="#" onclick="document.formGeneric.preselectedCountries = document.formIndex.preselectedCountries;"
Or

Expand|Select|Wrap|Line Numbers
  1. <a href="#" onclick="document.formGeneric.preselectedCountries[] = document.formIndex.preselectedCountries[];"
and others... but in vain.

I have searched around quite a bit, but did not find the solution. Can anyone give me a tip?! I would very much appreciate that. Thanks!
Nov 27 '12 #1

✓ answered by Rabbit

1) There is no HTML element of type array. You must be referring to the select element. It is not an array and does not function like an array.

2) If you are trying to reference the index of the selected row, you need to use the selectedIndex property.

3) That only works on single select lists. If you have a multi-select list, you need to loop through each option and check the selected property.

2 2480
Rabbit
12,516 Expert Mod 8TB
1) There is no HTML element of type array. You must be referring to the select element. It is not an array and does not function like an array.

2) If you are trying to reference the index of the selected row, you need to use the selectedIndex property.

3) That only works on single select lists. If you have a multi-select list, you need to loop through each option and check the selected property.
Nov 27 '12 #2
Ok, guess I need to go for the third solution then. Thanks!
Dec 3 '12 #3

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

Similar topics

1
by: vishal | last post by:
hi i am using get method to pass data from one form to another and my value may contain & symbol. so when this is case the value after & sign is truncated which is logically true. so what...
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...
11
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
6
by: Leszek | last post by:
Hi. I wrote a script: function zmiana(ile){ while(document.getElementById('accomp').childNodes.length>1){ ostatni=document.getElementById('document.dane.accomp').lastChild;...
7
by: al jones | last post by:
I'm not seeing things right today. I have an arraylist I create and load in one form. To display the information from the array list I'm opening a richtextbox in another form - stupid time - how...
1
by: czi02 | last post by:
hi there; for example, ive type my name on html frontpage cziarel then ive marquee it. Then ive type under my name cziarel Then I wanted to make my html go to other page when ive click on the...
2
by: SM | last post by:
Hello, Such a simple question and i can't find the answer(see code below). Here it is: I have a function: ini() In that function, i call a function (load_CDThumbnail) that creates an array and...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
1
by: Anaro | last post by:
Greetings This is all in VB.net 2005 I am trying to make a programme that will take in a completed survey and then store that survery object within an array. Currently i know my Surveyclass...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.