Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 How to add checkbox dynamically using javascript?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GoodMorningSky
Junior Member

122 Posts

Posted - 02 October 2003 :  17:50:57  Show Profile
I'm adding row in the table using createElement function using Javascript when user click a button.
But I want to add checkbox on the first column of eacch row being added.
How can I do it using javascript?
I can add text using createElement into <td> but, I don't know how to add checkbox into <td>..
Is it possible? if so, please reply.
And reply with how to get the value of the added check box in code in the case user click submit.
Thank you.



-- this is the function adding rows.
function addRow(id,strBarcode,strTranID){
var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];

var row = document.createElement("TR")

var td1 = document.createElement("TD")
td1.appendChild(document.createTextNode(" "))

var td2 = document.createElement("TD")
td2.appendChild (document.createTextNode(strBarcode))

var td3 = document.createElement("TD")
td3.appendChild (document.createTextNode(strTranID))

row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);

tbody.appendChild(row);
}

-- the row is added to following table in the page..
<table id="BarcodeTable" width="670" border="1" cellPadding="0" cellSpacing="0" topmargin="0" leftmargin="0">    
			<tbody>
				<tr>
					<td class="ColHeader" width=30 align=left style="font-weight:bold">  </td> 
					<td class="ColHeader" width=74 align=left style="font-weight:bold"> Barcode </td> 
					<td class="ColHeader" width=74 align=left style="font-weight:bold"> TranID </td> 
					<td class="ColHeader" width=74 align=left style="font-weight:bold"> ItemCode </td> 
					<td class="ColHeader" width=74 align=left style="font-weight:bold"> ColorID </td> 
					<td class="ColHeader" width=74 align=left style="font-weight:bold"> SizeID </td> 
				</tr> 
			</tbody>
		</table>		


Software Engineer.
MCSD.NET, SCWCD

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 02 October 2003 :  18:34:48  Show Profile  Visit HuwR's Homepage
document.execCommand("InsertInputCheckbox",false,"MYCHECKBOXID")

This will only work in Explorer. (and maybe Mozilla)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.29 seconds. Powered By: Snitz Forums 2000 Version 3.4.07