Advertise with us
Control Panel
Forum
Hosting Help
ASP.NET 4.5 & SQL 2012 Hosting
Resources
Notice
Login
Members
Shared Hosting
|
Upgrade
|
Advertise
|
Tutorials
|
Home
»
Resources
»
checkbox dynamic
ASP.NET
ADO.NET
Web Services
Remoting
Visual Studio 2005
Error Bank
Interview Questions
Tips & Tricks
XML
HTML
Jscript/Javascript
IIS
Windows
General
Submit Resource or code snippet
... and get
surprise gifts
Win Digital camera, ASP.NET Books, Free softwares!!
checkbox dynamic
03 Apr, 2008
Author:
nguyen tan loc
tracnghiem
Summary
creating checkbox dyanmic
.NET Classes used :
<<--
-
2
3
4
5
6
--->>
//javascript
function loadXMLDoc(filename)
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
}
catch(e) {alert(e.message)}
}
try
{
xmlDoc.async=false;
xmlDoc.load(filename);
return(xmlDoc);
}
catch(e) {alert(e.message)}
return(null);
}
function hienthitext()
{
listArea=document.getElementById('txtcauhoi').name
alert(listArea)
}
function fillLuaChon()
{
listItem=document.getElementById('cmbLuaChon')
//doc du lieu option tu xml
xml_source=loadXMLDoc("numberoption.xml")
opname=xml_source.getElementsByTagName("option")
for( var i=0;i
{
//tao tag option cho combobox
op=document.createElement('option')
//get value option 2,3,4,5,6
op.text=opname[i].childNodes[0].nodeValue
op.value=opname[i].childNodes[0].nodeValue
try
{
//them option vao combobox fire fox
listItem.add(op,null)
}
catch(ex)
{
//them cho IE
listItem.add(op)
}
}
//fill option vao combobox
hienthilistchoice(listItem.value)
}
function funca()
{
//if(document.getElementsByTagName('chkanswer').childNodes[0].checked==true)
//alert("co")
//alert(document.forms[0].txtchoices.length)
for( var i=0;i
alert(document.forms[0].txtchoices[i].value)
}
var chars="abcdefgh"
function hienthilistchoice(soluachon)
{
bodylist=document.getElementById('bodydiv')
//xoa cac checkbox tren form
if(bodylist.childNodes)
{
for( var k=0;k
bodylist.removeChild(bodylist.childNodes[k])
}
//liet ke cac choices
listchoice=document.createElement('OL')
for( var i=0;i
{
//liet ke cac choices
choiceitem = document.createElement('UL')
chkbox= document.createElement('INPUT')
chkbox.setAttribute('type','checkbox')
chkbox.setAttribute('name','chkanswer')
chkbox.setAttribute('value','chkanswer')
chkbox.setAttribute('onClick','funca()')
choicechar=document.createTextNode(chars.charAt(i) + ". ")
//set thuoc tinh cho txtarea nhap noi dung cho cau chon
txtchoice=document.createElement('textarea')
txtchoice.setAttribute('wrap','soft')
txtchoice.setAttribute('rows','2')
txtchoice.setAttribute('cols','50')
txtchoice.setAttribute('name','txtchoices')
choiceitem.appendChild(choicechar)
choiceitem.appendChild(chkbox)
choiceitem.appendChild(txtchoice)
listchoice.appendChild(choiceitem)
}
//them cac chon lua vao boby
bodylist.appendChild(listchoice)
}
//
Feedbacks about this page from members:
- No Feedbacks yet !! -
Submit Feedback
View All Feedbacks
Total
members
:
252387
Average new registrations per day (in last 7 days):
7
New Registration:
Open
Register Now
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
Advertise
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.