1

Is there a way to remove Form input/select values when you hide a div?

Example: Let say i have a form that i fill out. I have a couple different choices, each one will show a different div with a different form and hide the rest. But when i submit, it still submits those form values, even when the div is hidden.

Is it possible to remove all hidden form values?

I prefer jQuery if possible.

3 Answers 3

3
$(divyoujusthid).find(':input').attr('disabled', true);
Sign up to request clarification or add additional context in comments.

2 Comments

You can shorten the find to ':input'
With disabling, there seems to be a problem with IE7. Instead, i remove the values: $(':input:hidden').val("");
3

You could use the :hidden selector and disable all hidden inputs.

Ex:

$(':input:hidden').attr('disabled', true); 

Edit: changed from null to disabled, simplified selector per suggestion by Chaos

2 Comments

Suggest also using :input:hidden per Paolo Bergantino's comment to my answer.
updated... I must say that is awesome! Thanks Paolo and chaos :)
2

You can iterate through all of the input elements of the hidden div and disable them. Disabled form inputs do not submit anything.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.