<div class="crmr222">
<label id="isread-textt1111111111</label>
</div>
<div style="display:none;">
<div id="simTestContent" class="simScrollCont">
<div class="mainlist">
           <ul>
           <img src="../images/zfb.jpg" />
           </ul>
<ul>
<li><span>
                <select name="aaa" onchange="d()">
  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                </select>
                </span></li>
<li<span id="ccc">20000</span></li>
</ul>
</div> <div class="btnbox"><input type="button" id="confirmTerm" value="确认" onClick="confirmTerm(1);" class="confirmBtn"/></div>
</div><!--simTestContent end-->
</div>var showWindown = true;
function tipsWindown(title,content,width,height,drag,time,showbg,cssName,backcall) {
$("#windown-box").remove(); //请除内容
var width = width>= 950?this.width=950:this.width=width;     //设置最大窗口宽度
var height = height>= 527?this.height=527:this.height=height;  //设置最大窗口高度
if(showWindown == true) {
var simpleWindown_html = new String;
simpleWindown_html = "<div id=\"windownbg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;z-index: 999901\"></div>";
simpleWindown_html += "<div id=\"windown-box\">";
simpleWindown_html += "<div id=\"windown-title\"><h2></h2><span id=\"windown-close\">关闭</span></div>";
simpleWindown_html += "<div id=\"windown-content-border\"><div id=\"windown-content\"></div></div>"; 
simpleWindown_html += "</div>";
$("body").append(simpleWindown_html);
show = false;
}
contentType = content.substring(0,content.indexOf(":"));
content = content.substring(content.indexOf(":")+1,content.length);
switch(contentType) {
case "text":
$("#windown-content").html(content);
break;
case "id":
$("#windown-content").html($("#"+content+"").html());
break;
case "img":
$("#windown-content").ajaxStart(function() {
$(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
});
$.ajax({
error:function(){
$("#windown-content").html("<p class='windown-error'>加载数据出错...</p>");
},
success:function(html){
$("#windown-content").html("<img src="+content+" alt='' />");
}
});
break;
case "url":
var content_array=content.split("?");
$("#windown-content").ajaxStart(function(){
$(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
});
$.ajax({
type:content_array[0],
url:content_array[1],
data:content_array[2],
error:function(){
$("#windown-content").html("<p class='windown-error'>加载数据出错...</p>");
},
success:function(html){
$("#windown-content").html(html);
if(backcall)
backcall();
}
});
break;
case "iframe":
$("#windown-content").ajaxStart(function(){
$(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
});
$.ajax({
error:function(){
$("#windown-content").html("<p class='windown-error'>加载数据出错...</p>");
},
success:function(html){
$("#windown-content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+parseInt(height)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
}
});
}
$("#windown-title h2").html(title);
if(showbg == "true") {$("#windownbg").show();}else {$("#windownbg").remove();};
$("#windownbg").animate({opacity:"0.5"},"normal");//设置透明度
$("#windown-box").show();
if( height >= 527 ) {
$("#windown-title").css({width:(parseInt(width)+22)+"px"});
$("#windown-content").css({width:(parseInt(width)+17)+"px",height:height+"px"});
}else {
$("#windown-title").css({width:(parseInt(width)+10)+"px"});
$("#windown-content").css({width:width+"px",height:height+"px"});
}
var cw = document.documentElement.clientWidth,ch = document.documentElement.clientHeight,est = document.documentElement.scrollTop; 
var _version = $.browser.version;
if ( _version == 6.0 ) {
$("#windown-box").css({left:"50%",top:(parseInt((ch)/2)+est)+"px",marginTop: -((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
}else {
$("#windown-box").css({left:"50%",top:"50%",marginTop:-((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
};
var Drag_ID = document.getElementById("windown-box"),DragHead = document.getElementById("windown-title");

var moveX = 0,moveY = 0,moveTop,moveLeft = 0,moveable = false;
if ( _version == 6.0 ) {
moveTop = est;
}else {
moveTop = 0;
}
var sw = Drag_ID.scrollWidth,sh = Drag_ID.scrollHeight;
DragHead.onmouseover = function(e) {
if(drag == "true"){DragHead.style.cursor = "move";}else{DragHead.style.cursor = "default";}
};
DragHead.onmousedown = function(e) {
if(drag == "true"){moveable = true;}else{moveable = false;}
e = window.event?window.event:e;
var ol = Drag_ID.offsetLeft, ot = Drag_ID.offsetTop-moveTop;
moveX = e.clientX-ol;
moveY = e.clientY-ot;
document.onmousemove = function(e) {
if (moveable) {
e = window.event?window.event:e;
var x = e.clientX - moveX;
var y = e.clientY - moveY;
if ( x > 0 &&( x + sw < cw) && y > 0 && (y + sh < ch) ) {
Drag_ID.style.left = x + "px";
Drag_ID.style.top = parseInt(y+moveTop) + "px";
Drag_ID.style.margin = "auto";
}
}
}
document.onmouseup = function () {moveable = false;};
Drag_ID.onselectstart = function(e){return false;}
}
$("#windown-content").attr("class","windown-"+cssName);
if( time == "" || typeof(time) == "undefined") {
$("#windown-close").click(function() {
showselect('t123_')
$("#windownbg").remove();
$("#windown-box").fadeOut("slow",function(){$(this).remove();});
});
}else { 
setTimeout(closeWindown,time);
}
hideselect('t123_');
}
var closeWindown = function() {
showselect('t123_');
$("#windownbg").remove();
$("#windown-box").fadeOut("slow",function(){$(this).remove();});
}
function hideselect(per)
{
var _version = $.browser.version;
if ( _version == 6.0 ) {
$("select",document).each(function(){
if($(this).attr('name'))
{
if($(this).attr('name').substring(0,5)==per)
{
name = $(this).attr('name').substring(5);
$(this).attr('name',name);
$(this).css('display','');
}
if($(this).css('display')!='none')
{
name = per+$(this).attr('name');
$(this).attr('name',name);
}
$(this).css('display','none');
}
});
}
}
function showselect(per)
{
var _version = $.browser.version;
if ( _version == 6.0 ) {
$("select",document).each(function(){
if($(this).attr('name'))
{
if($(this).attr('name').substring(0,5)==per)
{
name = $(this).attr('name').substring(5);
$(this).attr('name',name);
$(this).css('display','');
}
}
});
}
}
function showTipsWindown(title,id,width,height){
tipsWindown(title,"id:"+id,width,height,"true","","true",id);
}function confirmTerm(s) {
parent.closeWindown();
if(s == 1) {
parent.document.getElementById("isread").checked = true;
}
}
//弹出层调用
function popTips(){
showTipsWindown("续期", 'simTestContent', 600, 285);
$("#isread").attr("checked", false);
}$(document).ready(function(){

$("#isread").click(popTips);
$("#isread-text").click(popTips);

});function popTipss(){
showTipsWindown("充值积分", 'simTestContentt', 600, 285);
}$(document).ready(function(){

$("#isreadd").click(popTipss);
$("#isread-textt").click(popTipss);

});var dc=document.getElementById("aaa");
$ddd=dc.options[dc.selectedIndex].value
document.getElementById("ccc").innerHTML=$ddd*2000;$ddd=dc.options[dc.selectedIndex].value
报缺少对象如果把div里style="display:none"删掉又正常救解

解决方案 »

  1.   

    TypeError: dc is null
    [在此错误处中断]  var dc=document.getElementById("aaa");--------
    你没有id=aaa的东西
    有个<select name="aaa"
    你加个id=aaa试试看看
      

  2.   

    你的代码没有与HTML分开,无法帮你分析。从错误代码看你的代码中确实缺少对象。
      

  3.   


    <style type="text/css">
    <!--
    .democode{width:400px;margin:30px auto 0 auto;line-height:24px;}
    .democode h2{font-size:14px;color:#3366cc;height:28px;}
    .agree{margin:40px auto;width:400px;font-size:16px;font-weight:800;color:#3366cc;}
    .mainlist{padding:10px; height:230px;}
    .mainlist ul{
    margin-top:10px;
    }
    .mainlist select{
    width:60px;
    }
    .mainlist li{height:36px;line-height:36px;font-size:12px; list-style:none;padding:0px;margin:0px;}
    .mainlist li span{margin:0 5px 0 0;font-family:"宋体";font-size:12px;font-weight:400;color:#ddd;}
    .mainlist .ttitle{width:100px; color:#000; display:inline-block;text-align:right;}
    .btnbox{text-align:center;height:30px;padding-top:10px;background:#ECF9FF;}#windownbg{display:none;position:absolute;width:100%;height:100%;background:#000;top:0;left:0;}
    #windown-box{position:fixed;_position:absolute;border:5px solid #E9F3FD;background:#FFF;text-align:left;}
    #windown-title{position:relative;height:30px;border:1px solid #A6C9E1;overflow:hidden;background:url(images/tipbg.png) 0 0 repeat-x;}
    #windown-title h2{position:relative;left:10px;top:-5px;font-size:14px;color:#666;}
    #windown-close{position:absolute;right:10px;top:8px;width:10px;height:16px;text-indent:-10em;overflow:hidden;background:url(images/tipbg.png) 100% -49px no-repeat;cursor:pointer;}
    #windown-content-border{position:relative;top:-1px;border:1px solid #A6C9E1;padding:5px 0 5px 5px;}
    #windown-content img,#windown-content iframe{display:block;}
    #windown-content .loading{position:absolute;left:50%;top:50%;margin-left:-8px;margin-top:-8px;}-->
    </style>
    <script src="http://static.dooct.com/crm/js/jquery.js" type="text/javascript"></script>
    <script>
    var showWindown = true;
    function tipsWindown(title,content,width,height,drag,time,showbg,cssName,backcall) {
    $("#windown-box").remove(); //请除内容
    var width = width>= 950?this.width=950:this.width=width;     //设置最大窗口宽度
    var height = height>= 527?this.height=527:this.height=height;  //设置最大窗口高度
    if(showWindown == true) {
    var simpleWindown_html = new String;
    simpleWindown_html = "<div id=\"windownbg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;z-index: 999901\"></div>";
    simpleWindown_html += "<div id=\"windown-box\">";
    simpleWindown_html += "<div id=\"windown-title\"><h2></h2><span id=\"windown-close\">关闭</span></div>";
    simpleWindown_html += "<div id=\"windown-content-border\"><div id=\"windown-content\"></div></div>"; 
    simpleWindown_html += "</div>";
    $("body").append(simpleWindown_html);
    show = false;
    }
    contentType = content.substring(0,content.indexOf(":"));
    content = content.substring(content.indexOf(":")+1,content.length);
    switch(contentType) {
    case "text":
    $("#windown-content").html(content);
    break;
    case "id":
    $("#windown-content").html($("#"+content+"").html());
    break;
    case "img":
    $("#windown-content").ajaxStart(function() {
    $(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
    });
    $.ajax({
    error:function(){
    $("#windown-content").html("<p class='windown-error'>加载数据出错...</p>");
    },
    success:function(html){
    $("#windown-content").html("<img src="+content+" alt='' />");
    }
    });
    break;
    case "url":
    var content_array=content.split("?");
    $("#windown-content").ajaxStart(function(){
    $(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
    });
    $.ajax({
    type:content_array[0],
    url:content_array[1],
    data:content_array[2],
    error:function(){
    $("#windown-content").html("<p class='windown-error'>加载数据出错...</p>");
    },
    success:function(html){
    $("#windown-content").html(html);
    if(backcall)
    backcall();
    }
    });
    break;
    case "iframe":
    $("#windown-content").ajaxStart(function(){
    $(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
    });
    $.ajax({
    error:function(){
    $("#windown-content").html("<p class='windown-error'>加载数据出错...</p>");
    },
    success:function(html){
    $("#windown-content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+parseInt(height)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
    }
    });
    }
    $("#windown-title h2").html(title);
    if(showbg == "true") {$("#windownbg").show();}else {$("#windownbg").remove();};
    $("#windownbg").animate({opacity:"0.5"},"normal");//设置透明度
    $("#windown-box").show();
    if( height >= 527 ) {
    $("#windown-title").css({width:(parseInt(width)+22)+"px"});
    $("#windown-content").css({width:(parseInt(width)+17)+"px",height:height+"px"});
    }else {
    $("#windown-title").css({width:(parseInt(width)+10)+"px"});
    $("#windown-content").css({width:width+"px",height:height+"px"});
    }
    var cw = document.documentElement.clientWidth,ch = document.documentElement.clientHeight,est = document.documentElement.scrollTop; 
    var _version = $.browser.version;
    if ( _version == 6.0 ) {
    $("#windown-box").css({left:"50%",top:(parseInt((ch)/2)+est)+"px",marginTop: -((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
    }else {
    $("#windown-box").css({left:"50%",top:"50%",marginTop:-((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
    };
    var Drag_ID = document.getElementById("windown-box"),DragHead = document.getElementById("windown-title");

    var moveX = 0,moveY = 0,moveTop,moveLeft = 0,moveable = false;
    if ( _version == 6.0 ) {
    moveTop = est;
    }else {
    moveTop = 0;
    }
    var sw = Drag_ID.scrollWidth,sh = Drag_ID.scrollHeight;
    DragHead.onmouseover = function(e) {
    if(drag == "true"){DragHead.style.cursor = "move";}else{DragHead.style.cursor = "default";}
    };
    DragHead.onmousedown = function(e) {
    if(drag == "true"){moveable = true;}else{moveable = false;}
    e = window.event?window.event:e;
    var ol = Drag_ID.offsetLeft, ot = Drag_ID.offsetTop-moveTop;
    moveX = e.clientX-ol;
    moveY = e.clientY-ot;
    document.onmousemove = function(e) {
    if (moveable) {
    e = window.event?window.event:e;
    var x = e.clientX - moveX;
    var y = e.clientY - moveY;
    if ( x > 0 &&( x + sw < cw) && y > 0 && (y + sh < ch) ) {
    Drag_ID.style.left = x + "px";
    Drag_ID.style.top = parseInt(y+moveTop) + "px";
    Drag_ID.style.margin = "auto";
    }
    }
    }
    document.onmouseup = function () {moveable = false;};
    Drag_ID.onselectstart = function(e){return false;}
    }
    $("#windown-content").attr("class","windown-"+cssName);
    if( time == "" || typeof(time) == "undefined") {
    $("#windown-close").click(function() {
    showselect('t123_')
    $("#windownbg").remove();
    $("#windown-box").fadeOut("slow",function(){$(this).remove();});
    });
    }else { 
    setTimeout(closeWindown,time);
    }
    hideselect('t123_');
    }
    var closeWindown = function() {
    showselect('t123_');
    $("#windownbg").remove();
    $("#windown-box").fadeOut("slow",function(){$(this).remove();});
    }
    function hideselect(per)
    {
    var _version = $.browser.version;
    if ( _version == 6.0 ) {
    $("select",document).each(function(){
    if($(this).attr('name'))
    {
    if($(this).attr('name').substring(0,5)==per)
    {
    name = $(this).attr('name').substring(5);
    $(this).attr('name',name);
    $(this).css('display','');
    }
    if($(this).css('display')!='none')
    {
    name = per+$(this).attr('name');
    $(this).attr('name',name);
    }
    $(this).css('display','none');
    }
    });
    }
    }
    function showselect(per)
    {
    var _version = $.browser.version;
    if ( _version == 6.0 ) {
    $("select",document).each(function(){
    if($(this).attr('name'))
    {
    if($(this).attr('name').substring(0,5)==per)
    {
    name = $(this).attr('name').substring(5);
    $(this).attr('name',name);
    $(this).css('display','');
    }
    }
    });
    }
    }
    function showTipsWindown(title,id,width,height){
    tipsWindown(title,"id:"+id,width,height,"true","","true",id);
    }function confirmTerm(s) {
    parent.closeWindown();
    if(s == 1) {
    parent.document.getElementById("isread").checked = true;
    }
    }
    //弹出层调用
    function popTips(){
    showTipsWindown("续期", 'simTestContent', 600, 285);
    $("#isread").attr("checked", false);
    }$(document).ready(function(){

    $("#isread").click(popTips);
    $("#isread-text").click(popTips);

    });
    function d()
    {
    var dc=document.getElementById("aaa");
    alert($ddd=dc.options[dc.selectedIndex].value);
    document.getElementById("ccc").innerHTML=$ddd*2000;
    }</script>
    <div>
    <ul>
    <label id="isread-text">点击弹出</label>
    </ul>
    </div>
    <div style="display:none;">
    <div id="simTestContent" class="simScrollCont">
    <div class="mainlist">
               <ul>
               <img src="../images/zfb.jpg" />
               </ul>
    <ul>
    <li><span class="ttitle">日期:</span><span></span></li>
    <li><span class="ttitle">年份:</span><span>
                    <select id="aaa" onChange="d()">
      <option value="1">1年</option>
                      <option value="2">2年</option>
                      <option value="3">3年</option>
                    </select>
                    </span>
                    </li>
    <li><span class="ttitle">结果:</span><span id="ccc">20000</span></li>
    </ul>
    </div> <div class="btnbox"><input type="button" id="confirmTerm" value="确认" onClick="confirmTerm(1);" class="confirmBtn"/></div>
    </div><!--simTestContent end-->
    </div>全整代码,点击弹出层,在弹出层里选择年份,然后年份乘2000赋给<span id=ccc></span>,如果把选择年份这块单独拿出一来运行一点问题都没有,加在弹出层了不行了。求解
      

  4.   

    放到弹出层后select的id重复了,document.getElementById获取到的是原来的aaa和ccc对象,隐藏起来的,而弹出层的并没有被更新改正这样就行了    function d(sel) {
            $(sel).closest('ul').find('#ccc').html(sel.value * 2000);
        }<select id="aaa" onChange="d(this)">