473,465 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what shall i do when the form name is an array?

i have two parts of code here
this is a javascript:
function addThirdTierCategory(){
var length = document.form.selectedCategory.options.length
var maxNum=10;
if(length >= maxNum){
alert('maximum selection exceeded');
return;
}
....................................
.................................................

the second line:
var length = document.form.selectedCategory.options.length
if i need to change the select box name from
selectedCategory into selectedCategory[]

like the following html code

<td colspan="2"><select multiple="multiple" size="10"
name="selectedCategory[]">
</select></td>

so later i could submit this form to a php file then i can read the
multiple selections, the problem i am having now is the select box
named "selectedCategory[] " is part of the multielevel selection box
which works with javascript, if i change the name in javascript: which
is from

document.form.selectedCategory.options.length
into
document.form.selectedCategory[].options.length

it reports error,

any one can give me some advice on it? thank you very much!!

Aug 6 '05 #1
3 1458
frey wrote:
i have two parts of code here
this is a javascript:
function addThirdTierCategory(){
var length = document.form.selectedCategory.options.length
You have an error here -----------^ that should be forms. I'll guess
it's just a copy/paste error.

[...]
so later i could submit this form to a php file then i can read the
multiple selections, the problem i am having now is the select box
named "selectedCategory[] " is part of the multielevel selection box
which works with javascript, if i change the name in javascript: which
is from

document.form.selectedCategory.options.length
into
document.form.selectedCategory[].options.length


document.forms['selectedCategory[]'].options.length

See the group faq:

<URL:http://www.jibbering.com/faq>

--
Rob
Aug 6 '05 #2
RobG wrote:
frey wrote:
i have two parts of code here
this is a javascript:
function addThirdTierCategory(){
var length = document.form.selectedCategory.options.length

You have an error here -----------^ that should be forms. I'll guess
it's just a copy/paste error.


Ooops, seems the name of your form may be 'form', so ignore the above.

[...]
[...]

document.forms['selectedCategory[]'].options.length

And if 'form' is your form name, then:

document.form.elements['selectedCategory[]'].options.length

will work somewhat better. :-)
See the group faq:

<URL:http://www.jibbering.com/faq>


<URL:http://www.jibbering.com/faq/#FAQ4_39>

--
Rob
Aug 6 '05 #3
problem solved, thanks rob

Aug 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: M.Siler | last post by:
<HTML> <HEAD> <TITLE></TITLE> <SCRIPT> <!-- var factor_val = new Array(8,7) factor_val = 68.8 factor_val = 55
1
by: vishal | last post by:
What does #line 182 parser.y mean in a C program?
15
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
11
by: bjrnove | last post by:
Hi. Me and a friend have a discussion about main. In my opinion the legal ways of writing main is: int main(void); int main(int,char**); My friend claims that you also have a standard...
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
2
by: tpaulson | last post by:
I have a couple of DIV's that I hide/display based on radio buttons. On the DIV's, I have multiple drop down boxes. The source shows that they are populated, but I can't make them drop down. Only...
5
by: Cylix | last post by:
this.menus = { root: new Array };
11
by: howa | last post by:
#include<iostream> using namespace std; int main(int argc, char* argv) { cout<<sizeof(argv) / sizeof(argv) ; return 0; };
6
by: Peter Lee | last post by:
what's the correct behaver about the following code ? ( C++ standard ) I got a very strange result.... class MyClass { public: MyClass(const char* p) { printf("ctor p=%s\n", p);
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
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
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...
0
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...
0
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,...
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.