473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to enable onclick event for checkboxes dynamically?

151 100+
Hi,

I need to generate check-boxes dynamically and enable onclick color change event for each check box. But I am unable to implement it by integrating Javascript code with Java.

// javascript code
Expand|Select|Wrap|Line Numbers
  1. out.println("<SCRIPT language= 'javascript' type='text/javascript'>function swapcol(item){if(document.getElementById(item).checked){document.getElementById(item+'bg').style.background='#D3D3D3'}else{document.getElementById(item+'bg').style.background='#FFFFFF'}}</SCRIPT>");
  2.  
//Calling Javascript function
Expand|Select|Wrap|Line Numbers
  1. for (int i =1; i <= 1; i++)
  2. {
  3.      String divid = null;
  4.      divid = Integer.toString(i);
  5.      String ide = null;
  6.      ide += "item";
  7.      ide += Integer.toString(i);
  8.      System.out.println(ide);
  9.      out.println("<DIV id=" + '1' +">Checkbox 1:   <INPUT type='checkbox' id=" + "item1" + "name='checkbox' onclick= swapcol(" + "item1"+ ")></DIV>");
  10. }
  11.  
May i know where i am wrong? Thanks in advance.
Dec 29 '11 #1
0 1549

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jim Mitchell | last post by:
I have some code behind that generates 10 imagebutton controls.... I can not seem to figure out how to trap the onclick event for each image and determine which image was clicked. Can someone...
1
by: MEM | last post by:
hello, I'd like to 'disable' an image link based on a value selected in a drop down. I currently have an image link that has the onclick event set to execute a function. For example:
17
by: abs | last post by:
My element: <span onclick="alert('test')" id="mySpan">test</span> Let's say that I don't know what is in this span's onclick event. Is it possible to add another action to this element's onclick...
1
by: Hrvoje Vrbanc | last post by:
Hello all! My question is the following: I add buttons (server controls) programatically into a table cell. Example: Dim btObnovi As Button = New Button() celija25.Controls.Add(btObnovi) ...
0
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
8
by: SalamElias | last post by:
I create 2 groupes of checkboxes dynamically (I don't use checkboxlist) for 2 differnet zones in my aspx web page and I assign a "onClick" javascript handler by group., lets say the first 4 chboxes...
11
by: Daz | last post by:
Hello everyone. I am sure the answer to my question is simple, but I can't seem to dynamically add an onClick event to my script. I have a table which is generated dynamically, I am just...
3
by: Michael_R_Banks | last post by:
I'm trying to dynamically build a table that allows users to remove rows when they click a corresponding button. For some reason, whenever I add the button to the table, it never fires the onclick...
7
by: Moses | last post by:
Hi Everybody, I have a problem with onClick event which works in FF and does not work in IE, Here I have giving the details Please help. I am creating a <aTag. dom_obj =...
1
by: RSH | last post by:
Hi, I have a page that is generating Linkbuttons dynamically. I need to dynamically wire up the buttons to an OnClick handler server side. I am using this code but they are not firing the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.