|
-
Nov 11th, 2010, 08:34 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] dynamic div and html table via jquery
here is the code snippt
Code:
<script type="text/javascript">
$(document).ready(function() {
$("input[name='group1']").change(function() {
$(".dynamicDiv").remove();
for (var j = 0; j < $("input[name='group1']:checked").val(); j++) {
$("<div />", { "class": "dynamicDiv", id: "div" + j, innerHTML: "div no:" + j
}).appendTo("body");
//var d = document;
}
}
);
});
</script>
Code:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<input id="Radio1" type="radio" value="1" name="group1" />1<br />
<input id="Radio2" type="radio" value="2" name="group1" />2<br />
<input id="Radio3" type="radio" value="3" name="group1" />3<br />
<input id="Radio4" type="radio" value="4" name="group1" />4<br />
<input id="Radio5" type="radio" value="5" name="group1" />5<br />
<input id="Radio6" type="radio" value="6" name="group1" />6<br />
<input id="Radio7" type="radio" value="7" name="group1" />7<br />
<input id="btn1" type="button" runat=server value="create div" onclick="createDiv();" />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
</form>
it created div as many as user select from radio button ,now i wantt to create table inside div (means in side loop).taht table then afterward holds label ,textbox validator et ctec
any help!!
There is no achievement without goals
-
Nov 11th, 2010, 08:35 PM
#2
Thread Starter
Fanatic Member
Re: dynamic div and html table via jquery
can any one help me how to do this ?? that i just mentioned in above post
There is no achievement without goals
-
Nov 12th, 2010, 12:32 PM
#3
Re: dynamic div and html table via jquery
Instead of immediately appending your newly created div to the body, you can append more stuff to it first:
Code:
//create div, assign to variable:
var myDiv = $("<div />", { "class": "dynamicDiv", id: "div" + j, innerHTML: "div no:" + j});
//append whatever you want to the div...
myDiv.append("<table><tr><td>first row of the table</td></tr></table>");
//append stuff to the table if you want...
$("table",myDiv).append("<tr><td>a second row in the table</td></tr>");
//when you're done making changes, append the div to the body like you were doing before:
myDiv.appendTo("body");
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|