题目:
搭建PHPNOW的开发环境,然后制作一个Html页面,并利用Javascript实现页面元素是否输入的校验,如果没有输入,则将焦点设置在该页面元素上
解答
PHPNOW环境搭建
系统:windows xp
- 将压缩包解压后,粘贴到虚拟机内,点击
setup,选择需要的Apache和MySql版本,我这里选择的是20和50,执行解压
输入y,进行初始化,设置mysql密码,这里设置为
123456设置完成:
- 输入密码,点击连接,测试成功
- 点击
phpMyAdmin,进入数据库管理页面,输入用户名root,密码123456
- 安装成功

制作Html页面
内容学习
安装Dreamweaver
htdocs文件夹为当前网站工作的根目录,在该目录先新建文件
js.htm,并用Dreamweaver打开
一个简单的html:
<html>
<head>
<title>Javascript example!</title>
</head>
<body>
1111
</body>
</html>
document.write()函数
<html>
<head>
<title>Javascript简单示例</title>
<script language="javascript">
for(i=1;i<=100;i++){
num=Math.floor(Math.random()*100);//0-99之间的随机数
document.write(num," ");//向body区域写入内容
}
</script>
</head>
<body>
</body>
</html>
函数调用
<html> |
利用设计界面插入按钮
更改按钮名称
效果:
声明对象
<html>
<head>
<title>Javascript example</title>
</head>
<body>
<script language="javascript">
function student(name,school,grade){
this.name=name;
this.school=school;
this.grade=grade;
}
hui=new student("nothing_gonna","xx school","seconde grade");
with(hui)
{ document.write(name+":"+school+","+grade+"<br/>");}
if(window.hui){
document.write("object hui exists");
}
else
document.write("object hui doen't exists");
</script>
</body>
</html>
验证文本框输入内容
<html> |
利用Javascript实现页面元素是否输入的校验,如果没有输入,则将焦点设置在该页面元素上
==设置焦点的函数:document.getElementById(“文本域的id”).focus();==
<html> |
==提交按钮的type应该使button而不是submit,否则点击后会刷新表单并清空⬇⬇⬇⬇⬇⬇==
==chrome浏览器无法正常运行该文件,这里使用Microsoft edge可以正常使用==





All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.

