I have a problem with my form querystring being too long.
I plan on solving this problem by simply disabling all un-used form elements before submit. But I need help on making this js function...
You need to know that I have a js-function which shows sub-categories whenever a main-category is chosen. This happens "onChange
" on a drop-list. So "onChange
" of the category drop-list, the correct DIV
is made visible by using javascript, and therefore making subcategories visible for the user to specify (users may chose color, make, year etc etc in subcategories).
For instance, if you chose "Cars" from the main category drop list, the js function will make the DIV
which contains all "Cars" options visible (color, make, year etc). Then if you chose another category, say "Trucks", "Cars" is made invisible, and the "Trucks" DIV is made visible. Simple.
However, my problem is that even if the DIVs are not visible at the moment, the form elements inside them gets submitted anyways. This is completely unneccessary. So, I need a javascript function which could be integrated into the already existing function which hides/shows the sub-category DIVs, which would disable all elements inside unused DIVs.
Here is the function which shows/hides sub-category DIVs, and is triggered onChange of the main category drop-list:
var category=document.nav_form_main.nav_category_list.value;
(category=="Cars")?byId("nav_sub_cars").style.display='block' : byId("nav_sub_cars").style.display='none';
(category=="Trucks")?byId("nav_sub_trucks").style.display='block' : byId("nav_sub_trucks").style.display='none';
I would like something like this:
(category=="Cars")?byId("nav_sub_cars").style.display='block' : disableDiv("nav_sub_cars");
function disableDiv(divId){
Disable all form elements inside divId
AND
make divId invisible.
}
NOTE: The divs contain only form elements, and tables. In other words, I don't care if all elements inside the div are disabled. By form elements, I mean: Text inputs, Select lists, Checkboxes and Radios.
I don't know much js at all, so any help in making this function which shouldn't be too hard is appreciated...
Thanks