aspose file tools*
The moose likes Struts and the fly likes problem in giving onChange event in s:combobox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in giving onChange event in s:combobox" Watch "problem in giving onChange event in s:combobox" New topic
Author

problem in giving onChange event in s:combobox

dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
Hi,

I am trying to give onChange event in combobox in strtuts2
Actually I want to make it like if user selects particular value from combobox then some fields will show up in same page. so, i am giving javascript code too, but still its not going.!

My Code is



and javascript is



But its not going in that function even the first line is also not printing.. i tried all onselect, onclick and onchange but none of them works. Let me know If i can do like this or not or if there is any other way to do it

Thanks
Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
This particular event's proper functioning might depend on the
browser as well, have you tried the same with different browsers?


"Eppur si muove!"
dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
i am making this application in eclipse and checking on that only but its not showing me up there
Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
dhaval tamboli wrote:i am making this application in eclipse and checking on that only but its not showing me up there


Can you try different external browsers (e.g. Chrome, Firefox, IE) in Eclipse...and see the results...
dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
I tried using both firefox and IE but its still same. I am not sure is this the only way to call javascript function? cause its not going in there!!
Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
dhaval tamboli wrote:I tried using both firefox and IE but its still same. I am not sure is this the only way to call javascript function? cause its not going in there!!


Maybe this discussion might give you some clues?
dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
HI, I think my problem is total different.

I am posting whole jsp page as such it will extend once I can find combobox's selected value.

Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

I tested your code and it functions, but maybe not the way you think it should. If you view the generated HTML code, the onselect event is on the input box. If you select something from the select box and then select the text in the input box the event will fire.

Also, you should be calling alert in your function, not System.out.println.
dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
Hi,

I got your point but I dont know how to see generated html code and also I am confused regarding fetching combobox's value in javascript.

Thanks
Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
dhaval tamboli wrote:I dont know how to see generated html code...


You can see generated html code by selecting the View Page Source option in your browser.
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

You cannot get the selected value in the combo box, you will have to get the value from the text box. If you assign an id to your combo box, the id is assigned to the text box and you can get the value from the text box.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just out of curiosity, what do you believe this is going to do?!?!
 
Don't get me started about those stupid light bulbs.
 
subject: problem in giving onChange event in s:combobox