aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes handling onclick event by creating buttons dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "handling onclick event by creating buttons dynamically" Watch "handling onclick event by creating buttons dynamically" New topic

handling onclick event by creating buttons dynamically

Pragnyan Dalei

Joined: Dec 28, 2011
Posts: 11

I am not getting why this code is not working . :( can Any one suggest how to handle this onclick event. I am generating the button dynamically. when I click on the button I need some funtionality to be I want to display 1 alert message.

Thanks in advance.

[Edit - added code tags - MB]
Matthew Brown

Joined: Apr 06, 2010
Posts: 4519

I'd recommend looking at the error console or a Javascript debugger and seeing if you get any errors recorded. If you do, and that doesn't make the problem clear, let us know what the error was.
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Why are you using java scriptlet in your JSP? One of the first things you're going to hear in this forum is to replace your scriptlet code with JSTL.

However, I think the bigger problem may be the javascript assignment of the variable event:

Where is "event" being assigned here?

In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62307

Indeed. Java scriptlets have been discredited since 2002 when JSP 2 was introduced. Using scriptlets in moderne JSP pages is nothing short of irresponsible.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Have you tried LearnNowOnline?
subject: handling onclick event by creating buttons dynamically