Click to See Complete Forum and Search --> : Keeping some form elements from being submitted


zeb
08-04-2005, 09:09 AM
Is there a way to prevent certain form elements from being submitted with a form? I have some forms that have select menus and a few check boxes that only serve as tools to the user filling out the form - much like the vB code options here in the forums above the "Post Thread" text area. The problem is that these tools are available for many different text fields per form and it becomes a lot of superfluous data to be passed to the server and then to be filtered with my scripts.

Kor
08-05-2005, 04:08 AM
give no name to those elements, and their values woun't be submitted. Or give those elements display:none onsubmit.

zeb
08-05-2005, 12:03 PM
Thanks Kor. I switch the "name" to "id" so I wouldn't loose the ability to access these elements with JS. That seemed to do the trick with the elements not being sent with the form, but are there any possible conflicts with using id over name? It's my understanding that "id" is preferred, but as far as JS is concerned are there any technical differences between the two? I will be able to find out on my own, but it takes time to debug all the JS that was written with the elements all having a "name" attribute. At a quick glance, it appears to be unaffected by this change.

felgall
08-05-2005, 04:57 PM
The best way to resolve problems between name and id is to make them the same value whereever you include both on the same field (except for radio buttons).

zeb
08-05-2005, 05:31 PM
Right, but in this case I'm explicitly not including the name attribute so that the form elements don't get submitted with the form.

Kravvitz
08-06-2005, 06:53 PM
Yes, IDs and names are treated differently at least some of the time in different browsers.

If you set the <input>, <select>, or <textarea>'s disabled attribute then their information won't be submitted.

zeb
08-07-2005, 08:29 AM
The select menus need to be functional. Setting the disabled attribute would not allow selections to be made.

I think everything is working fine now. Thanks!