<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>多文件上传</title>
<script type="text/javascript" src="\SQL\selectdate.js"></script>
<script language="JavaScript">
<!--
//动态添加控件
function addSelection() {
var i = 0;
i = form1.myi.value;
var str = "<span name=" + i + " id=" + i + ">字段条件:<select id=\"dp_fileds" + i + "\" style=\"width: 140px\" onchange='indexchange(this)'> <option selected=selected value=string>姓名<\/option> " + "<option value=date>日期<\/option>" + "<option value=int>id<\/option> <\/select> <select id=\"dp_case" + i + "\" name=\"tiaojian\" style=\"width: 55px\"> <option selected=\"selected\" value=\">\">大于<\/option> <option value=\"<\">小于<\/option> <option value=\"like\">相似<\/option> <option value=\"<>\">不等<\/option> <\/select> <input id=\"dp_andor" + i + "\" style=\"width: 121px\" type=\"text\" \/> <select id=\"dp_andor" + i + "\" name=\"andOr\" style=\"width: 53px\"> <option selected=\"selected\" value=\"or\">或者<\/option> <option value=\"and\">并且<\/option> <\/select><br><\/span>";
document.getElementById('MyFile').innerHTML += str;
i++;
form1.myi.value = i;
}
function DelFile() { document.all.MyFile.removeChild(MyFile.lastChild);
} function test() {
var i = 0;
for (i = 0; i < MyFile.children.length; i++) {
if (MyFile.children[i].children[2].value != '') { alert(MyFile.children[i].children[2].value);
}
}
// alert('childNodes:'+MyFile.childNodes.length+'\nchildren:'+MyFile.children.length);
//document.all.MyFile.removeChild(MyFile.lastChild);
}
function indexchange(objSelect) {
//动态添加事件,当选择数据类型是日期时文本框生成时间选择器,当数字时验证数字···
//但这里事件添加不上是为什么?
if (objSelect.options[objSelect.selectedIndex].value == "date") {
objSelect.parentNode.childNodes[2].setAttribute("onclick", eval(function() {
javascript: DateControl20(this)
}));
}
}
-->
</script>
</HEAD>
<body>
<form id="form1" method="post" encType="multipart/form-data" runat="server">
<input onclick="addSelection()" type="button" value="增加(Add)">
<input type="hidden" value="1" name="myi">
<input onclick="DelSelection()" type="button" value="删除" name="btnDel0">
<input onclick="test()" type="button" value="test" name="btntst0">
<div id="MyFile"></div>
</form>
</body>
</HTML>
<HTML>
<HEAD>
<title>多文件上传</title>
<script type="text/javascript" src="\SQL\selectdate.js"></script>
<script language="JavaScript">
<!--
//动态添加控件
function addSelection() {
var i = 0;
i = form1.myi.value;
var str = "<span name=" + i + " id=" + i + ">字段条件:<select id=\"dp_fileds" + i + "\" style=\"width: 140px\" onchange='indexchange(this)'> <option selected=selected value=string>姓名<\/option> " + "<option value=date>日期<\/option>" + "<option value=int>id<\/option> <\/select> <select id=\"dp_case" + i + "\" name=\"tiaojian\" style=\"width: 55px\"> <option selected=\"selected\" value=\">\">大于<\/option> <option value=\"<\">小于<\/option> <option value=\"like\">相似<\/option> <option value=\"<>\">不等<\/option> <\/select> <input id=\"dp_andor" + i + "\" style=\"width: 121px\" type=\"text\" \/> <select id=\"dp_andor" + i + "\" name=\"andOr\" style=\"width: 53px\"> <option selected=\"selected\" value=\"or\">或者<\/option> <option value=\"and\">并且<\/option> <\/select><br><\/span>";
document.getElementById('MyFile').innerHTML += str;
i++;
form1.myi.value = i;
}
function DelFile() { document.all.MyFile.removeChild(MyFile.lastChild);
} function test() {
var i = 0;
for (i = 0; i < MyFile.children.length; i++) {
if (MyFile.children[i].children[2].value != '') { alert(MyFile.children[i].children[2].value);
}
}
// alert('childNodes:'+MyFile.childNodes.length+'\nchildren:'+MyFile.children.length);
//document.all.MyFile.removeChild(MyFile.lastChild);
}
function indexchange(objSelect) {
//动态添加事件,当选择数据类型是日期时文本框生成时间选择器,当数字时验证数字···
//但这里事件添加不上是为什么?
if (objSelect.options[objSelect.selectedIndex].value == "date") {
objSelect.parentNode.childNodes[2].setAttribute("onclick", eval(function() {
javascript: DateControl20(this)
}));
}
}
-->
</script>
</HEAD>
<body>
<form id="form1" method="post" encType="multipart/form-data" runat="server">
<input onclick="addSelection()" type="button" value="增加(Add)">
<input type="hidden" value="1" name="myi">
<input onclick="DelSelection()" type="button" value="删除" name="btnDel0">
<input onclick="test()" type="button" value="test" name="btntst0">
<div id="MyFile"></div>
</form>
</body>
</HTML>
解决方案 »
- 如何用dreamweaver画统计图
- 动态显示嵌入网页的宽度和高度,急!
- 如何将-moz-opacity放入jquery中的 json数据
- 点击表格某列,显示该列的列数.............
- 以下代码为什么在本地调试显示正常,而传到网站后就不行了?显示效果不完全正确.
- 元素位置的问题(紧急)
- 请教脚本问题??谢谢
- 我想用Javascript达到这种效果,请问该怎么做?
- 在ASP+vbscript/javascript中,如何实现数据表格的图表化,就像股票的走势图,或者直方图等等,请赐教!!
- 十分急!如何在分帧的网页上做浮动图片?急!请大家帮忙!
- 一个简单的,有时间就进来帮个忙
- 请教高手一个option选项的问题
javascript: DateControl20(this)
}));为什么我在这里动态添加用户控件的时候没有添加上呢?还有什么方法呢?
//动态添加事件,当选择数据类型是日期时文本框生成时间选择器,当数字时验证数字···
//但这里事件添加不上是为什么?
if (objSelect.options[objSelect.selectedIndex].value == "date") {
objSelect.parentNode.childNodes[2].onclick=function(){
javascript: DateControl20(this)
}();
}
}
现在的代码为 if (objSelect.options[objSelect.selectedIndex].value == "date") {
alert(objSelect.parentNode.children[2].value);
objSelect.parentNode.children[2].onclick=function(){
javascript: DateControl20(objSelect.parentNode.children[2])
}();
}
但是出现的效果好象不对,我需要的是在文本框单击以后弹出日历框,可现在是在单选框选择以后跳出,而单击文本框没有出来
html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="selectdate.js"></script>
<script type="text/javascript" src="XmlHttpPool.js"></script>
<script language="JavaScript">
<!--
function addSelection() {
var i = 0;
i = form1.myi.value;
if( MyFile.lastChild!=null)
{ document.getElementsByName("btnDel0").disabled=false;
document.getElementById('MyFile').lastChild.children[3].disabled=false;
}
var str = "<span name=" + i + " id=" + i + ">字段条件:<select id=\"dp_fileds" + i + "\" style=\"width: 140px\"> <option selected=selected value=string>姓名<\/option> " + "<option value=date>日期<\/option>" + "<option value=int>id<\/option> <\/select> <select id=\"dp_case" + i + "\" name=\"tiaojian\" style=\"width: 55px\"> <option selected=\"selected\" value=\">\">大于<\/option> <option value=\"<\">小于<\/option> <option value=\"like\">相似<\/option> <option value=\"<>\">不等<\/option> <\/select> <input id=\"dp_andor" + i + "\" style=\"width: 121px\" type=\"text\" onclick='chktext(this)'\/> <select id=\"dp_andor" + i + "\" name=\"andOr\" style=\"width: 53px\" disabled=true > <option selected=\"selected\" value=\"or\">或者<\/option> <option value=\"and\">并且<\/option> <\/select><br><\/span>";
document.getElementById('MyFile').innerHTML += str;
i++;
form1.myi.value = i;
}
/**********************************************/
function DelSelection() {
if( MyFile.lastChild!=null)
{document.all.MyFile.removeChild(MyFile.lastChild);
if( MyFile.lastChild!=null)
{
MyFile.lastChild.children[3].disabled=true;
}else
{
document.all.getElementsByName("btnDel0").disabled=true;
}
}
}
/***********************************************/
function test() {
var i = 0;
var str='';
for (i = 0; i < MyFile.children.length; i++) {
if (MyFile.children[i].children[2].value != '') { str+=MyFile.children[i].children[2].value+'|';
}
}
PostJs(str);
// alert('childNodes:'+MyFile.childNodes.length+'\nchildren:'+MyFile.children.length);
//document.all.MyFile.removeChild(MyFile.lastChild);
}
function chktext(objSelect)
{
var type=objSelect.parentNode.children[0].options[objSelect.parentNode.children[0].selectedIndex].value;
if(type=="string")
{
//alert("string");
}else if(type=="date")
{
DateControl20(objSelect);
}else
{
// alert(type);
// objSelect.disabled=true; }
}
function indexchange(objSelect) {
if (objSelect.options[objSelect.selectedIndex].value == "date") {
alert(objSelect.parentNode.children[2].value);
objSelect.parentNode.children[2].onclick=function(){
javascript: DateControl20(objSelect.parentNode.children[2])
}();
}
}
/************************************************/
function PostJs(postdata)
{
var str = postdata; //要传给后台的js
var ServerUrl = 'Handler.ashx';//数据处理页面
__XmlHttpPool__.GetRemoteData(ServerUrl+'?OptType=Post&Str='+str,this.BackJs);
}
function BackJs(rev)
{
document.getElementById("plantext").innerHTML=rev;
//alert(rev);//返回的字符串的值
}
-->
</script>
</head>
<body>
<form id="form1" runat="server">
<input onclick="addSelection()" type="button" value="增加(Add)">
<input type="hidden" value="1" name="myi">
<input onclick="DelSelection()" type="button" value="删除" name="btnDel0">
<input onclick="test()" type="button" value="test" name="btntst0">
<div id="MyFile"></div>
<div id="plantext"></div>
</form>
</body>
</html>