baidu_32212355 2015-10-26 13:45 采纳率: 0%
浏览 2634

js,html问题:为什么我的的新窗口无法显示出那两个for语句的值




<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>输入页</title>
<script language="javascript">

function check()
{
 var a=document.getElementById("myname").value;
 var b=document.getElementById("mysex").value;
 var c=document.getElementById("myage").value;
 var d=document.getElementById("mytel").value;
 var e=document.getElementById("myadd").value;
 var f=document.getElementById("imgOne").value;
 var g=document.getElementById("hobby").value;
 if(a==""||a==null)
{
    alert("基本信息姓名未填!");
    ff.myname.focus();
    return;
}
 if(b==""||b==null)
{
    alert("基本信息性别未填!");
    ff.mysex.focus();
    return;
}
if(c==""||c==null)
{
    alert("基本信息年龄未填!");
    ff.myage.focus();
    return;
}
if(d==""||d==null)
{
    alert("基本信息电话未填!");
    ff.mytel.focus();
    return;
}
if(e==""||e==null)
{
    alert("基本信息地址未填!");
    ff.myadd.focus();
    return;
}
if(f==""||f==null)
{
    alert("基本信息照片未填!");
    ff.mypic.focus();
    return;
}
if(g.length<="1")
{
    alert("爱好特长字数过少!");
    ff.hobby.focus();
    return;
}
else newpage();

}

//function newpage()
//{
/*
    var a=document.getElementById("myname").value;
    var b=document.getElementById("mysex").value;
    var c=document.getElementById("myage").value;
    var d=document.getElementById("mytel").value;
    var e=document.getElementById("myadd").value;
    var f=url;
    var g=document.getElementById("hobby").value;
    var dw;var txtid;
        dw=window.document.open();
        dw=document.write("<html><head><title>一个新的窗口</title>");
        dw=document.write("<style typewox='text/css'>");
        dw=document.write("div#ff{width:55%;margin:auto;}");
        dw=document.write("div#grjl {background-color:#77baab;}");
        dw=document.write("div#jbxx {height:250px;width:70%;float:left;}");
        dw=document.write("div#pic {height:250px;width:5%;float:right;}");
        dw=document.write("h1 {margin-bottom:0;text-align:center;}");
        dw=document.write("h2 {margin-bottom:0;font-size:18px;}");
        dw=document.write("</style>");
        dw=document.write("</head><body>");
        dw=document.write("<div id='ff'>");
        dw=document.write("<div id='grjl'><h1>个人简历</h1></div>");
        dw=document.write("<div id='jbxx'><h2>基本信息</h2>");
        dw=document.write("<div id='pic'><img src="+f+" width='200' height='210'></div>");
        dw=document.write("姓名:"+a+"<br /><br />");
        dw=document.write("性别:"+b+"<br /><br />");
        dw=document.write("年龄:"+c+"<br /><br />");
        dw=document.write("住址:"+e+"<br /><br />");
        dw=document.write("电话:"+d+"<br /><br /><br />");
        dw=document.write("<div id='edu'><h2>教育经历</h2>");
        dw=document.write("<ul>");
        for(var i=0;i<nub;i++){
            txtid=educ[i];
            dw.write("<li>"+printText(txtid)+"</li>");
        };
        dw=document.write("</ul>");
        dw=document.write("</div>");
        dw=document.write("<div name='jiang'><h2>奖励奖项</h2>");
        dw=document.write("<ul>");
        for(var i=0;i<num;i++){
            txtid=hno[i];
            dw.write("<li>"+printText(txtid)+"</li>");
        };

        dw=document.write("</ul></div>");
        dw=document.write("<div name='NewHobby'><h2>爱好特长</h2><br />");
        dw=document.write(""+hobby+"</div>");
        dw=document.write("</div></div></body></html>");
        dw.document.close();

*///}


var nub=0;
var educ= new Array();
function addText1()
        {
            nub++;
            var txt=document.createElement("input");
            var br=document.createElement("br");
            txt.type="text";
            txt.id="txt"+nub.toString();
            educ[nub]=txt.id;
            txt.placeholder="请输入";
            document.getElementById("edu").appendChild(br);
            document.getElementById("edu").appendChild(txt);
        }


var num=0;
var hno=new Array();    
function addText()
        {
            num++;
            var txtt=document.createElement("input");
            var br=document.createElement("br");
            txtt.type="text";
            txtt.id="text"+num.toString();
            hno[num]=txtt.id;
            txtt.placeholder="请输入";
            document.getElementById("jiang").appendChild(br);
            document.getElementById("jiang").appendChild(txtt);
        }

function newpage()
{
    var a=document.getElementById("myname").value;
    var b=document.getElementById("mysex").value;
    var c=document.getElementById("myage").value;
    var d=document.getElementById("mytel").value;
    var e=document.getElementById("myadd").value;
    var f=url;
    var g=document.getElementById("hobby").value;
    var dw;var txtid;
        dw=window.document.open();
        dw=document.write("<html><head><title>一个新的窗口</title>");
        dw=document.write("<style typewox='text/css'>");
        dw=document.write("div#ff{width:55%;margin:auto;}");
        dw=document.write("div#grjl {background-color:#77baab;}");
        dw=document.write("div#jbxx {height:250px;width:70%;float:left;}");
        dw=document.write("div#pic {height:250px;width:5%;float:right;}");
        dw=document.write("h1 {margin-bottom:0;text-align:center;}");
        dw=document.write("h2 {margin-bottom:0;font-size:18px;}");
        dw=document.write("</style>");
        dw=document.write("</head><body>");
        dw=document.write("<div id='ff'>");
        dw=document.write("<div id='grjl'><h1>个人简历</h1></div>");
        dw=document.write("<div id='jbxx'><h2>基本信息</h2>");
        dw=document.write("<div id='pic'><img src="+f+" width='200' height='210'></div>");
        dw=document.write("姓名:"+a+"<br /><br />");
        dw=document.write("性别:"+b+"<br /><br />");
        dw=document.write("年龄:"+c+"<br /><br />");
        dw=document.write("住址:"+e+"<br /><br />");
        dw=document.write("电话:"+d+"<br /><br /><br />");
        dw=document.write("<div id='edu'><h2>教育经历</h2>");
        dw=document.write("<ul>");
        for(var i=0;i<nub;i++){
            txtid=educ[i];
            dw.write("<li>"+printText(txtid)+"</li>");
        };
        dw=document.write("</ul>");
        dw=document.write("</div>");
        dw=document.write("<div name='jiang'><h2>奖励奖项</h2>");
        dw=document.write("<ul>");
        for(var i=0;i<num;i++){
            txtid=hno[i];
            dw.write("<li>"+printText(txtid)+"</li>");
        };

        dw=document.write("</ul></div>");
        dw=document.write("<div name='NewHobby'><h2>爱好特长</h2><br />");
        dw=document.write(""+hobby+"</div>");
        dw=document.write("</div></div></body></html>");
        dw.document.close();

}

var url;
function getFileUrl(sourceId) {

        if (navigator.userAgent.indexOf("MSIE") >= 1 && !(navigator.userAgent.indexOf("MSIE 10.0") > 0) ) { 
            //url = document.getElementById(sourceId).value;
            document.all.imgOne.select();
            $("#preview").focus();
            url = document.selection.createRange().text;

        } else if (navigator.userAgent.indexOf("Firefox") > 0) { // Firefox 
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        } else if (navigator.userAgent.indexOf("Chrome") > 0) { // Chrome 
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }else if(navigator.userAgent.indexOf("MSIE 10.0") > 0){
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }else{
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }
        return url;
    }
 function preImg(sourceId, targetId) {
        var url = getFileUrl(sourceId);
        var imgPre = document.getElementById(targetId);
         if(window.navigator.userAgent.indexOf("MSIE") >= 1 && !(navigator.userAgent.indexOf("MSIE 10.0") > 0) ) {
             var picpreview=document.getElementById("preview");
             picpreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = url;
         }else{
             imgPre.src = url;
         }

    }
</script>
<h3>基本信息</h3>
<form name="ff" id="ff">
<div style="width:400px;height:550px;background:#9FF"id="jbxx">
<ul>
    <li>请输入姓名:</li><input type="text"name="myname"id="myname"placeholder="必填项"></li>
    <li>请输入性别:</li><input type="text" name="mysex"id="mysex"placeholder="必填项" ></li>
    <li>请输入年龄:</li><input type="text"name="myage"id="myage"placeholder="必填项"></li>
    <li>请输入电话:</li><input type="text"name="mytel"id="mytel"placeholder="必填项"></li>
    <li>请输入住址:</li><input type="text"name="myadd"id="myadd"placeholder="必填项"></li>
</ul>   
请输入照片:<input type="file" name="imgOne" id="imgOne" onchange="preImg(this.id,'imgPre');" /> 
<div id="preview"width:200px;height:210px;border:solid 1px black;">
  <div align="right"><img src="" name="imgPre" width="200" height="210px" align="left" id="imgPre" style="display: block;" /></div>
</div>
</div>
<hr width="1340" size="1" />
<div id="edu">
<h3>教育经历</h3>
<span class="STYLE1">请输入从初中开始至今的教育经历:</span>
</div>
<input type="button" name="btn1" value="动态添加文本框" onclick="addText1();" />
<hr width="1340" size="1" />
<div id="jiang">
<h3>获奖经历</h3>
<span class="STYLE1">请输入你获得的任何奖励:</span>
</div>
<input type="button" name="btn2" value="动态添加文本框" onclick="addText();" />
<hr width="1340" size="1" />
<h3>爱好特长:</h3>
<div id="fm">
请输入你的爱好特长,不少于20字:<br></br>
<textarea id="hobby"></textarea> 
<hr width="1340" size="1" />
</div>
<input name="提交" type="button" onclick="check()" value="提交"/>
<input type="reset" value="重置" />
</form>
</body>
</html>

  • 写回答

7条回答

  • baidu_32212355 2015-10-26 13:48
    关注

    啊啊啊啊啊为什么没有分段!

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮