Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

form.action in IE  RSS feed

 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

I have a problem with the DOM form object. I'm trying to change it's action, but I can't get it to work in IE.
This code is inside a function called by a button's onClick event:

It works fine in FF, though.
 
Charbel Keyrouz
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show more code please.
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JSP and Servlets. In some of my pages I have this button:

temDisponibilidade is irrelevant since it is with the correct value (true).

Now the JS:

Where Manter.go will go by my servlet. In FF, when the request reaches the servlet, request.getServletPath() is already "/Manter.go", so it will process the business logic and forward to a certain JSP. In IE request.getServletPath() is with the old value ("Reportes.go"), so it will process the current page again. From this I can only presume that IE doesn't recognize form.action property.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and what does


look like when you view the page source in IE?

Eric
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and you said it did not work if you did

document.btnIncluir.action = "asdf";

Eric
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what you were trying to say, but I tried that code and it didn't work.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have anything named action in your form/page?

Eric
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, every form has an action.

http://www.w3schools.com/htmldom/dom_obj_form.asp
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not what he asked.
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, if there is any misregard here please clarify things to me. I still didn't understand what I am doing wrong in the code, neither what he is trying to tell me.

Edit: got the point. There really was a hidden field named action in my JSP, so IE was setting it's value instead of the form's value. Sorry for bothering you guys.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common problem with "action" and "submit". They should never be used as names in HTML form elements.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!