Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delete form field

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34105
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34105
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34105
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a solution for Netscape 4.7 but it involves deleting more than just a form field!

Jules
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34105
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic