Preventing form items from being sent to the server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
enchance
Forum Commoner
Posts: 34
Joined: Sat Sep 15, 2007 12:10 pm

Preventing form items from being sent to the server

Post by enchance »

Usually, when clicking on a 'submit' button, the form sends all the 'value' attributes within the form to the server. But is there a way to not send the 'value' attribute of form elements which are invisible (style="display:none")? :?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Preventing form items from being sent to the server

Post by requinix »

You could use JavaScript to actually remove the elements from the form.

But otherwise no. Can't you just ignore them?
enchance
Forum Commoner
Posts: 34
Joined: Sat Sep 15, 2007 12:10 pm

Re: Preventing form items from being sent to the server

Post by enchance »

I got it and the answers pretty simple too! Just add disabled="disabled" to the item and it won't be sent along with $_POST. How ironic that I was thinking of using AJAX or PHP when HTML could already do the trick for me. This proves that the right answer we're looking for is sometimes just under our noses. :mrgreen:
Post Reply