《JavaSprict程序设计》实验报告五 表 单_第1页
《JavaSprict程序设计》实验报告五 表 单_第2页
《JavaSprict程序设计》实验报告五 表 单_第3页
《JavaSprict程序设计》实验报告五 表 单_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

《JavaSprict程序设计》实验报告五一、实验目的掌握浏览器对象的层次关系,掌握表单和表单元素的概念。2.正确理解表单对象的属性和方法,及如何应用表单元素。二、实验内容在教材P156例8-1的基础上作以下改动,其中在新窗口输出结果可参考例7-1。1.title及显示标题改为“实验五:表单”2.“男性”和“女性”的选择为具有相同name属性的radio对象的单选按钮。3.单击页面上的“确定”按钮将弹出新的页面,输出原来页面所输入的个人信息。运行效果请参考以下截图:三、HTML文件代码:(做好的html文件调试运行后,将所有程序代码复制在下面)<html>

<head>

<title>实验五:表单</title>

<script

language="javascript">

function

longchecks(s)

{

return

s.length;

}

function

overchecke()

{

if(longchecks(document.basicinfo.username.value)==0)

{

alert("姓名不能为空!");

}

else

if(document.basicinfo.usersex[0].checked==false

&&

document.basicinfo.usersex[1].checked==false)

{

alert("请选择性别!");

}

else

if(longchecks(document.basicinfo.userage.value)==0)

{

alert("年龄不能为空!");

}

else

if(longchecks(document.basicinfo.userwork.value)==0)

{

alert("单位不能为空!");

}

else

if(longchecks(document.basicinfo.userphone.value)==0)

{

alert("电话不能为空!");

}

else

{

var

w=window.open("","");

var

d=w.document;

d.write("<html><head><title>个人信息</title></head>");

d.write('<body><h4>基本信息:</h4><form

name="info"><font

size="2">姓名:</font><input

type="text"

size=40

value="'+document.basicinfo.username.value+'"><br><br>');

d.write('<font

size="2">性别:</font><input

type="text"size=40

value="');

if

(document.basicinfo.usersex[0].checked==true)

{d.write(document.basicinfo.usersex[0].value+'"><br><br>');}

else{d.write(document.basicinfo.usersex[1].value+'"><br><br>');}

d.write('<font

size="2">年龄:</font><input

type="text"size=40

value="'+document.basicinfo.userage.value+'"><br><br>');

d.write('<font

size="2">单位:</font><input

type="text"size=40

value="'+document.basicinfo.userwork.value+'"><br><br>');

d.write('<font

size="2">电话:</font><input

type="text"size=40

value="'+document.basicinfo.userphone.value+'"><br><br>');

d.write('<body><h4>其他信息:</h4><font

size="3">向往的职业:</font><br><input

type="text"size=46

value="'+document.otherinfo.occupation.value+'"><br><br>');

d.write('<font

size="3">喜欢的运动:</font><br><input

type="text"size=46

value="');

var

k=false;

for

(var

i=0;i<5;i++)

{

if

(document.otherinfo.sport[i].checked==true)

{

if

(k==true)

{d.write(',');}

d.write(document.otherinfo.sport[i].value);

k=true;

}

}

d.write('"><br><br>');

d.write("</form></body></html>");

}

}

</script>

</head>

<body>

<h3>实验五:表单</h3>

<form

name="basicinfo">

<h4>请输入您的基本信息(必须填写)</h4>

<font

size="2">您的姓名:</font>

<input

type="text"name="username"><br>

<font

size="2">您的性别:</font>

<input

type="radio"name="usersex"value="男">男性   

<input

type="radio"name="usersex"value="女">女性<br>

<font

size="2">您的年龄:</font>

<input

type="text"name="userage"><br>

<font

size="2">所在单位:</font>

<input

type="text"name="userwork"><br>

<font

size="2">电话号码:</font>

<input

type="text"name="userphone"><br>

</form>

<form

name="otherinfo">

<h4>请输入您的其他信息</h4>

<font

size="2">排球您向往的职业:</font>

<select

name="occupation">

<option

value="教师"selected>教师</option>

<option

value="军官">军官</option>

<option

value="技术人员">技术人员</option>

<option

value="运动员">运动员</option>

</select><br>

<font

size="2">您喜欢的运动:</font><br>

<input

type="checkbox"name="sport"value="足球">足球   <input

type="checkbox"name="sport"value="篮球">篮球   <input

type="checkbox"name="sport"value="排球">排球<br>

<input

type="checkbox"name="sport"value="羽毛球">羽毛球   <input

type="checkbox"name="sport"value="乒乓球">乒乓球<br><br>

<font

size="2">请给我们留言:</font>

<textarea

name=

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论