Solved

How to exclude some input from post?

Posted on 2009-05-11
9
655 Views
Last Modified: 2013-12-12
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?
0
Comment
Question by:DLJB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 39

Accepted Solution

by:
abel earned 250 total points
ID: 24353472
Do not set their runat="server" value, if you create these items declaratively in the HTML of the ASPX, or change them from being an input type to being a (hidden) label type, which will not become part of the POST array.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24353592
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>
0
 
LVL 14

Expert Comment

by:shobinsun
ID: 24353597
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).
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:DLJB
ID: 31580099
Thanks!
0
 
LVL 39

Expert Comment

by:abel
ID: 24353652
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... ;)
0
 
LVL 39

Expert Comment

by:abel
ID: 24353660
@alien109: a disabled element will still be sent to the server in the POST. It is, however, disabled for receiving user input.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24354048
0
 
LVL 39

Expert Comment

by:abel
ID: 24354167
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.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24354919
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!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question