| Author |
Page submission on change of drop down value not working
|
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Hi All,
I came across a roadblock while developing my web app that uses JSP's .I use beans ,servlets and a JSP as view component. In my JSP , I have a form which has a dropdown as one of it's elements .The JSP also has a dynamically populated table that is populated on the basis of the selection in the drop down.
For this I have written the neccessary logic in my DAO layer , however Im confused as to how to reload the page based on the change in drop down value. As of now im using javascript.Somethign like this,
and the referencing html tag is
Am I doing something wrong?
Im a newbie and any help would be appreciated.
Thanks.
|
Learning and Learning!-- Java all the way!
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
Submitting the form under script control is fine.
One suggestion I would make: stop using all uppercase for your html. That's so 1996.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Hi Bear,
Thanks for replying.I am using JS , however the table does not refresh upon changing the value in the drop down , upon running the code in firefox , firebug pointed out an error on the
document.form.action="Main.jsp?DTobjid"; line
Why is this?
Please help
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
|
I always use document.getElementById() to address elements. It's a lot less fragile than the old-fashioned methods.
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Im sorry , but i didnt get what you meant.
I am using document.getElementById and its working fine too.
document.getElementById('selectedval').value=DTobjid;
However the error i face is at--
document.form.action="Main.jsp?DTobjid";
any pointers?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
Vic Hood wrote:I am using document.getElementById ...
But not here:
document.form.action="Main.jsp?DTobjid";
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
|
Im sorry i didnt quite get what you meant in the above post :s
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
|
document.form bad. document.getElementById() good.
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Again,Bear.
I really dont get what you mean?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
|
Use document.getElementById() to fetch references to elements. Always.
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Once again.
I am ]using document.getElementById()
In the lines.
what I m trying to figure out here
is how to submit to the form in the lines..
Hope you understand .
EDIT:Human error
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
I don't care about the other lines. "document.form" is a loser! Use document.getElementById() to get the reference to the form element.
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Thanks for the advice!works fine now. Here's the new snippet
where the form had an id='Main'
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
Though I'd suggest a better name than "Main".
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 477
|
|
Point taken!
|
 |
 |
|
|
subject: Page submission on change of drop down value not working
|
|
|