Link to home
Start Free TrialLog in
Avatar of DLJB
DLJB

asked on

How to exclude some input from post?

1-I have one form with several text inputs.
2-I'm using POS ACTION.
3-I want that some inputs dont go to the POST array.

How do I do that?
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try setting their disabled property on submit

<script type="text/javascript">
function disable() {
    document.getElementById("bob").disabled = true;
}
</script>

<form id="test" action="" onsubmit="disable()">
<input type="text" name="bob" id="bob" value="" />
</form>
Avatar of shobinsun
Hi,

As mentioned from the previous post, you can use the hidden fields . but make sure that name attribute is not set  to the hidden field.
If they don't have a "name" attribute, they won't be submitted (will not be in the POST array).
Avatar of DLJB
DLJB

ASKER

Thanks!
the information from shobinson is correct for internet explorer only. firefox will send the ID if the name is not present. And if you use only an ID on an element that is server-sided (i.e. runat="server") then, for all input types, ASP.NET will automatically add the Name as well, which means: you need some extra tweaking for that hack to work... ;)
@alien109: a disabled element will still be sent to the server in the POST. It is, however, disabled for receiving user input.
Interesting. Apparently I am mixing readonly/disabled. The key line here is "Controls that are  disabled cannot be successful." (and successful means: cannot be submitted). Thanks for pointing that out to me.
No problem abel. I've used this technique quite a bit in the past, so I was a bit nervous when you said that :) Had to do some quick tests and research!