<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>制作模板,第一步</title>
</head>
<script language="javascript">
function ajaxFunction()
{
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();
}
catch(e){
try{
xmlHttp=new ActiveXObject(Msxml2.XMLHTTP);
}
catch(e){
try{
xmlHttp=new ActiveXObject(Msxml.XMLHTTP);
}
catch(e){
alert('您的瀏覽器不支持AJAX!');
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if (xmlHttp.Readystate==4)
{
var dd1=document.getElementById("DropDownList1");
var index=dd1.selectIndex;
var aaa=dd1.options[index].value;
alert("aaa"); //這里無法執行
}
}
xmlHttp.open("GET","",true);
//xmlHttp.send(Null);
}
</script>
<body>
<form name="form1" method="post" action="" runat="server">
<table width="80%" align="center" style="border:solid 1px #4397c5; padding:0;">
<tr style="border:solid 1px #4397c5">
<td height="27" colspan="4">新增產品頁面模板</td>
</tr>
<tr style="margin:0px;">
<td style="width: 107px; border:solid 1px #4397c5; margin:-2px; height: 25px;">模板名稱</td>
<td style="width: 237px; height: 25px;"><input type="text" name="tf_module_name" value="產品模板"></td>
<td style="width: 115px; height: 25px;">模板行數</td>
<td width="27%" style="height: 25px">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<div id="rownum">
</div>
</table>
<table>
里面動態生成模板的行數
</table>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dynamicAdd.aspx.cs" Inherits="WebApp.dynamicAdd" %>
<!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></title>
<script type="text/javascript">
function addFile() {
var _table = document.createElement("table");
var _tbody = document.createElement("TBODY");
var _row;
var _cell;
var rlen = parseInt(document.getElementById("rowlen").value);
for (var i = 0; i < rlen; i++) {
_row = document.createElement("tr");
for (var j = 0; j < 3; j++) {
_cell = document.createElement("td");
var div = document.createElement("div");
var f = document.createElement("input");
f.setAttribute("type", "text")
f.setAttribute("name", "txtCardNo")
f.setAttribute("size", "20")
div.appendChild(f)
var d = document.createElement("input");
d.setAttribute("type", "button")
d.setAttribute("onclick", "deteFile(this)");
d.setAttribute("value", "移除")
div.appendChild(d)
_cell.appendChild(div);
_row.appendChild(_cell);
}
_tbody.appendChild(_row);
}
_table.appendChild(_tbody);
var con = document.getElementById("_container");
con.innerHTML = "";
con.appendChild(_table);
}
function deteFile(o) {
while (o.tagName != "DIV") o = o.parentNode;
o.parentNode.removeChild(o);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<select id="rowlen">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input value="add" type="button" onclick="addFile()" />
<div id="_container">
</div>
<input type="submit" value="ok" />
</form>
</body>
</html>
<script language="javascript">
var xmlHttp = false;
function CreateXMLHttpRequest(){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function StartRequest(RequestUrl,HandleFunctionName){
CreateXMLHttpRequest();
xmlHttp.open("GET",RequestUrl,false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlHttp.setRequestHeader("charset", "utf-8");
xmlHttp.onreadystatechange = HandleFunctionName;
xmlHttp.send(null);
}
function GetData() {
var listType = document.all.DropDownList1.options[document.all.DropDownList1.selectedIndex].value;
var Url = "Data.aspx?Type=" + listType;
StartRequest(Url, HandleReload);
}
function change() {
GetData();
}
function HandleReload() {
try {
if (xmlHttp.readyState == 4) {
var returnHtml = xmlHttp.responseText;
document.getElementById("rownum").innerHTML = returnHtml;
}
}
catch(e) {
window.alert(e);
}
}
</script>
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。