By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
problem solved, thanks rob

Aug 6 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.