| Author |
delete form field
|
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Is it possible to delete a form field? I'm trying to get the field to be null so that my JSP doesn't see it as a parameter. I tried the following, but it returns the string "null" when I do request.getParameter() in my JSP.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56200
|
|
I'd just beef up the server-side code so that it will ignore the parameter when the value is null, but if you insist on dealing with it client-side you can use DOM manipulation to remove the element from the page. Using the 'display:none' CSS rule won't work since different browsers treat it differently (some will still submit the parameter, some won't). Client-side manipulation is just too squirrelly for my tastes so I'll repeat my recommendation to deal with it server-side.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
|
|
Hi Jeanne, When I worked with IE4 a few years ago it didn't submit disabled fields. We had to write special JS to enable and re-disable read-only fields either side of the submit (using the readOnly property had other issues, in case you're wondering). I dunno if that's still the case but it may be worth a shot. Jules
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Bear, I'm sort of stuck with this code as it is in a framework developed by another team. I am going to try to get them to change it, but I have to work around this problem in the meantime. So unless you know a way of changing the parameters in the request, I have to do this. This is a hidden field, so it wouldn't be displayed anyway. I'll try the DOM idea and Jules' disable suggestion tomorrow. I will put a comment that the javascript is a hack and should be removed
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Both of those solutions work in IE. Unfortunately, neither works in Netscape 4.7, which we are required to support. I'll do some more research on netscape 4.7 and see if I can come up with anything.
|
 |
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
|
|
I have a solution for Netscape 4.7 but it involves deleting more than just a form field! Jules
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
It doesn't seem possible to get arond this in NS 4.7. I wound up doing a server side hack (copying the method) until it is fixed.
|
 |
 |
|
|
subject: delete form field
|
|
|