js赋值,如果有两个或者以上重复的ID怎么办? 用document.all.abc.value='1';这样来给一个form中的ID为abc赋值,但是问题是,如果表单中有两个重复ID均为abc怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用document.all.abc.value='1';这样来给一个form中的ID为abc赋值,但是问题是,如果表单中有两个重复ID均为abc怎么办? 应该用不同的ID吗?但是表单当初设计的时候,用数组读出来就成了重复ID了。。再试试看能修改表单不 IDidentity 表示唯一性,身份证号码一样 明白了那能问另外一个问题吗?ajax页面无法直接写<script></script>,那应该如何在后台页面输出js后,自动进行js赋值处理呢?比如asp处理页面中输出结果为:<script>document.all.abc.value="123";</script>这样在html中似乎无法用ajax来加载,如何自动的执行 document.all.abc.value="123";这句呢? 误导。页面上的id当然可以重复,如果重复获document.getElementById('youID')获得是的是一个array[]数组。如果是单id ,document.getElementById('youID')获得是对象object自动进行js赋值处理,可以使用eval(str);str是你的js处理字符串, 好像不能输出啊?我是不是写错了?html中的ajax代码:function getuser(str){ xmlhttp.open('get',"getname.asp?tid=userid="+(str)+"&sn="+Math.random(),true); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState==4){ document.getElementById("userinfo").innerHTML =unescape(xmlhttp.responseText); } } xmlhttp.setRequestHeader("If-Modified-Since","0"); xmlhttp.send(null); }asp处理页面getname.asp:<%Response.Write("eval(document.writeln('OK');)")%>似乎html页面中只返回了eval(document.writeln('OK');)这一句而没有被执行。。 id可以重复,但是一般不这么做,如果有重复的ID,document.getElementById('youID')返回的应该是第一个匹配的元素吧!? function getuser(str){ xmlhttp.open('get',"getname.asp?tid=userid="+(str)+"&sn="+Math.random(),true); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState==4){ document.getElementById("userinfo").innerHTML =unescape(xmlhttp.responseText); } } xmlhttp.setRequestHeader("If-Modified-Since","0"); xmlhttp.send(null); }楼主你上面那些写直接输出要显示的值就可以了,不要带js代码,如果带js代码的话<%Response.Write("alert(123)")%> xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState==4){ eval(xmlhttp.responseText); } } [原创]jQuery在线演示大全 JS 的一些兼容性问题,帮忙解决下~~ 下拉列表的几个问题 有关给一个对象添加事件的问题 如何实现以下字符串的功能 js改变frame地址 使用模态窗口遇到的问题??? 一个关于窗口自动关闭的问题 关于checkbox的问题!在线! jquery this用法 方法传参数 动态删除表格tr 请教:全选 和 反选 checkbox 请教如何捕获ctrl键?
identity 表示唯一性,身份证号码一样
那能问另外一个问题吗?ajax页面无法直接写<script></script>,那应该如何在后台页面输出js后,自动进行js赋值处理呢?
比如asp处理页面中输出结果为:<script>document.all.abc.value="123";</script>这样在html中似乎无法用ajax来加载,如何自动的执行 document.all.abc.value="123";这句呢?
页面上的id当然可以重复,如果重复获document.getElementById('youID')获得是的是一个array[]数组。
如果是单id ,document.getElementById('youID')获得是对象object自动进行js赋值处理,可以使用eval(str);
str是你的js处理字符串,
html中的ajax代码:
function getuser(str){
xmlhttp.open('get',"getname.asp?tid=userid="+(str)+"&sn="+Math.random(),true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4){
document.getElementById("userinfo").innerHTML =unescape(xmlhttp.responseText);
}
}
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}asp处理页面getname.asp:<%
Response.Write("eval(document.writeln('OK');)")
%>似乎html页面中只返回了eval(document.writeln('OK');)这一句而没有被执行。。
function getuser(str){
xmlhttp.open('get',"getname.asp?tid=userid="+(str)+"&sn="+Math.random(),true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4){
document.getElementById("userinfo").innerHTML =unescape(xmlhttp.responseText);
}
}
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}楼主你上面那些写直接输出要显示的值就可以了,不要带js代码,如果带js代码的话<%
Response.Write("alert(123)")
%>
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4){
eval(xmlhttp.responseText);
}
}