JScript for the .NET Framework


div element delete


i have code
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="gfln1.WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Javascript create new div</title>
<style type="text/css">
.dynamicDiv { width : 200px; height : 100px; border : solid 1px #c0c0c0; background - color : #e1e1e1; font - size : 11px; font - family : verdana; color : #000; padding : 5px; }
</style>
<script type="text/javascript" language="javascript">
function createDiv() {
var divTag = document.createElement("div");
divTag.id = "div1";
divTag.setAttribute("align", "center");
divTag.style.margin = "0px auto";
divTag.className = "dynamicDiv";
divTag.innerHTML = "This HTML Div tag is created using Javascript DOM dynamically.";
document.body.appendChild(divTag);
}
function createDiv1() {
for (var i = 0; i < document.form1.group1.length; i++) {
if (document.form1.group1[i].checked) {
alert(parseInt(document.form1.group1[i].value));
for (var j = 0; j < parseInt(document.form1.group1[i].value); j++) {
var divTag = document.createElement("div");
divTag.id = "div" + j ;
divTag.setAttribute("align", "center");
divTag.style.margin = "0px auto";
divTag.className = "dynamicDiv";
divTag.innerHTML = "div" + j
document.body.appendChild(divTag);
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<input id="Radio1" type="radio" value=1 name=group1 onclick="createDiv1();" />1<br />
<input id="Radio2" type="radio" value=2 name=group1 onclick="createDiv1();"/>2<br />
<input id="btn1" type="button" runat=server value="create div" onclick="createDiv();" />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
</form>
</body>
</html>
if i click on radio button 1 only one div create ,if i click on 2 two div created and first div removed ,please change my code in such a maaner
ERUM
Hi,
Find below-
<%# Page Language="C#" AutoEventWireup="true" CodeFile="DynamicDIV.aspx.cs" Inherits="DynamicDIV" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Javascript create new div</title>
<style type="text/css">
.dynamicDiv { width : 200px; height : 100px; border : solid 1px #c0c0c0; background - color : #e1e1e1; font - size : 11px; font - family : verdana; color : #000; padding : 5px; }
</style>
<script type="text/javascript" language="javascript">
function createDiv() {
var divTag = document.createElement("div");
divTag.id = "div1";
divTag.setAttribute("align", "center");
divTag.style.margin = "0px auto";
divTag.className = "dynamicDiv";
divTag.innerHTML = "This HTML Div tag is created using Javascript DOM dynamically.";
var container = document.getElementById("container");
container.innerHTML = "";
container.appendChild(divTag);
}
function createDiv1() {
var container = document.getElementById("container");
container.innerHTML = "";
for (var i = 0; i < document.form2.group1.length; i++) {
if (document.form2.group1[i].checked) {
for (var j = 0; j < parseInt(document.form2.group1[i].value); j++) {
var divTag = document.createElement("div");
divTag.id = "div" + j ;
divTag.setAttribute("align", "center");
divTag.style.margin = "0px auto";
divTag.className = "dynamicDiv";
divTag.innerHTML = "div" + j
container.appendChild(divTag);
}
}
}
}
</script>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<input id="Radio1" type="radio" value=1 name=group1 onclick="createDiv();" />1<br />
<input id="Radio2" type="radio" value=2 name=group1 onclick="createDiv1();"/>2<br />
<input id="btn1" type="button" runat=server value="create div" onclick="createDiv();" />
<div id="container"></div>
</div>
</form>
</body>
</html>
Thanks AnupDG

Related Links

How to Enable a RadioButton in ClientSide???????
IMG onclick error
URGENT: Time Session for my Internet Banking Project
InfoPath JScript - Loop through repeating elements in a Data Source programmatically
jquery intellesnese
To display a Yes/No dialog box after reading a file !!
Is there a VBScript for .NET?
Microsoft.JScript.Vsa.VsaEngine
HOWTO set a AJAX:TabContainer's height in javascript at run time.
Consume Web Service with Transport Layer Security (HTTPS) from JavaScript
Multi-threading in javascript
Click handler on popup does not run properly in a .NET environment
How to update ASP.NET image control periodically?
Format date before SQL Query execution
Alert window in aspx page.
Class doesn't support automation - or - how to install WS 5.7 on an XP SP3

Categories

MSDN
Visual Studio Team Fou...
BizTalk Server
Commerce Server
HealthVault
Office Live Development
Silverlight
Archived Forums Visual...
Forums Issues (not pro...
Visual Studio Setup an...
Visual Studio LightSwi...
Tools for Apache Cordova
App & Ad Unit Management
XboxLiveDevelopment
Developing Windows Des...
Application Security f...
Windows Filtering Plat...
SharePoint 2013 - Gene...
SharePoint 2013 - Deve...
SharePoint Legacy Vers...
SharePoint Legacy Vers...
Service Bus
Azure CDN
Azure Log Analytics
Machine Learning
Azure DevTest Labs
Team Foundation Server...
Architecture General
BizTalk Server General
Commerce Server 2007
ADO.NET Entity Framewo...
Code Contracts
Microsoft Translator D...
Visual Basic for Appli...
Microsoft Robotics - H...
Visual Studio Smart De...
SQL Server Replication
SQL Server Documentation
SQL Server Application...
SQL Server PowerPivot ...
SQL Server Distributed...
Standard 7: Tools
Standard 7: Misc
Windows Embedded Compa...
SQL Server 2012 SQL To...
Windows Forms General
Windows Forms Designer
Windows Server 2008 Ap...
SDK for Home Server 20...
Windows Live Messenger...
CRM
MSDN and TechNet Searc...
Orchard –Discussions
WebsitePanel - Support
Bing Maps REST, SOAP, ...
Office Live Basics, Es...
SharePoint Server Prot...
Windows File Sharing P...
Microsoft Lync Persist...
PivotViewer Control wi...
Retired SharePoint Col...
.NET Framework 4 Appli...
.NET Framework 4: Wind...
Building Windows Store...
Chart Controls for .NE...
Feedback for Visual Ba...
HD DVD Interactivity A...
Git, Mercurial and Dro...
POS for .NET
Server Core Developers
Software Transactional...
SQL Server 2014 In-Mem...
Using Visual Round Tri...
Visual Basic Power Packs
Visual Studio Performa...
WCF Data Services (Pre...
Windows Developer Prev...
Windows MultiPoint Mou...
Windows Presentation F...
Building Windows Store...
Mango Update (Archived)
XNA Framework
Kinect for Windows v1 SDK
Cortana Skills Kit

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile