aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes javascript help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript help" Watch "javascript help" New topic
Author

javascript help

purnima arora
Greenhorn

Joined: May 27, 2008
Posts: 3
Hi All
I am new to java and jsp and this is my first project, but facing some issues. As per our project requirements we have to display the check-boxes equal to number of values in the database, and i have to also call a function on onclick event on this checkbox. but i am not able to do so.
[ May 28, 2008: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
UseAMeaningfulSubjectLine

Also, see
EaseUp to find out why adding "urgent", "asap", or in this case "HELP REQUIRED!!" to your message or subject line can actually slow down or halt responses to your question altogether.




Again, welcome to JavaRanch and good luck with your question.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

I'm going to move this to the JavaScript forum since it is not about Portlets.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

but i am not able to do so.
Why not? What have you written so far? What isn't working about it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
well I'm sure you can do a query to the database and return some sort of DataSet when the page loads, and then just echo(response.write, whatever) checkbox's out with their values equal to the unique id of each row in the database.

this way when you click, and have some operation you execute on click of a button, you'll have the id of that row id in the value of the checkbox and can operate just fine.

As far as executing a function that will modify the database when you click a checkbox (what I'm assuming your doing) you can use AJAX.

send a request with the ID of the row append to the url with a GET. Then on the server side you can get the ID and do what you wish. Then when the server is done and has wrote something like "DB operation successfull!" then you can get the response in the client side with AJAX.

This way you never have to refresh or anything like that.

Justin


You down with OOP? Yeah you know me!
purnima arora
Greenhorn

Joined: May 27, 2008
Posts: 3
Hi Justin

Thanks for the quick response but we dont want to update the database by the javascript function.

We want to function to enable other set of checkboxes when this particular checkbox is clicked. so we want to call a javascript function on onclick event for this particular checkbox.

But the problem we are facing is we are not able to call that particular function since the check-boxes are dynamic.
if you can help us out with that.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi Purnima,

Are the checkboxes generated from the business logic or using JSP and javaScript? In either case if you can also add a 'onChange()' javaScript function call to them so that when the values in the checkkboxes are changed a javaScript function is invoked where you can enable or disable the other set of checkboxes. I mentioned 'onChange()' because I think you want to enable or disable the second set of checkboxes based on the value or even a change of value in the first? IS this what you are looking for?

Cheers,
Raj.
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
when you are creating the checkbox's dynamically, set their id attribute, and their onclick attribute and then you can get the element by it's id uniquely.



then just define your disableAll() function...



Hope this helps,

Justin Fox

[ May 29, 2008: Message edited by: Justin Fox ]
[ May 29, 2008: Message edited by: Justin Fox ]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Better yet, if you put your 'blocks' of checkboxes in forms, you can just disable/enable the forms when the checkbox is clicked, which will automatically disable/enable the checkbox's within that form.

Justin Fox
purnima arora
Greenhorn

Joined: May 27, 2008
Posts: 3
Hi Justin

The code that you had given is for dynamically generating checkboxes with javascript and we are dynamically generating those check-boxes with scriplet, that is why we are not able to assign an id to a check-box properly.

With Regards
Purnima
[ June 02, 2008: Message edited by: Bear Bibeault ]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Oh, well that's no good.

there's not a method in java for registering a script block from
the server?

I don't use JSP so I'm just trying to help .

Justin
 
 
subject: javascript help