PHPl中的js代码怎么放进js文件中,然后在PHP中调用。新手,分不多,请多多帮助。源码如下:

<input type="text" id="1" disabled > +
<input type="text" id="2" />=
<input type="text" id="3" disabled>
<input type="button" value="验证结果" onclick="yanz()"/>
<input type="button" value="下一题" onclick="goBack()">
<input type="button" value="查看结果" onclick="chak()"/>

<script>
var shurk1=document.getElementById("1");
var shurk2=document.getElementById("2");
var shurk3=document.getElementById("3");
shu();
function shu(){
var a=(Math.floor(Math.random()*10+1));
var b=(Math.floor(Math.random()*10+1));
if (a>=b){
shu();
}else{
shurk1.value=a;
shurk3.value=b;}
}
function yanz(){
if (isNaN(shurk2.value) || isNaN(shurk1.value)){
alert("输入正确的数");
shurk2.value="";return;
}else{
bij();}
}
function bij(){
var a=shurk1.value;
var b=shurk3.value;
var c=shurk2.value;
if (b*1==a*1+c*1){
alert ("正确");
document.getElementById("2").disabled=true;
}else{
alert ("错误");
document.getElementById("2").disabled=true;
}
}
function goBack(){
window.history.go(-13);
shurk2.value="";
if (document.getElementById("2").disabled=true){
document.getElementById("2").disabled=false;shu()
}else{
document.getElementById("2").disabled=true;shu();}
}
</script>

新建个文件夹,把下面的代码放入文件里$(function(){
$("#KinSlideshow").KinSlideshow({
moveStyle:"down",
intervalTime:8,
mouseEvent:"mouseover",
titleFont:{TitleFont_size:14,TitleFont_color:"#FF0000"}
});
})
然后文件保存后缀为 .js
接着在你的页面的放入<script type="text/javascript" src="你js文件和html网页在一个文件下的路径"></script>;追问

先谢了,分给你了。我在自己看看吧!

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-09-06
把script标签里的内容放到一个新的文件比如 aaa.js
然后到调用页面 如下:
<html>
<head>
<script src="aaa.js"></script>
</head>
<body>
</body>
</html>追问

那我上面定义的var 怎么办也写到JS里面吗?

追答

肯定啊符合javascript 语法不会出错就行

追问



+
=

上面是写在PHP里面的内容

相似回答