| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1502 人关注过本帖
标题:特郁闷,刚学javascript,照书上去上机实践老出问题,怎么没结果显示?超简 ...
只看楼主 加入收藏
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
结帖率:83.33%
收藏
 问题点数:0 回复次数:12 
特郁闷,刚学javascript,照书上去上机实践老出问题,怎么没结果显示?超简单的
<html>
<head>
<title>无标题文档</title>
</head>
<body >
<script language="javascript">
var astr="开始";
var aname=astr.anchor("start");
document.write(aname);
</script>
</body>
</html>


怎么都没显示呀?效果应该和<a name ="star">开始</a>是一样的呀!
搜索更多相关主题的帖子: 结果 上机 javascript 实践 
2007-08-15 23:14
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
收藏
得分:0 
奇怪,刚又能正常运行了,这到底怎么回事?我电脑有问题?
2007-08-15 23:49
ibmsun
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-8-9
收藏
得分:0 

你程序是要建立苗点连接吧, 没有连接苗点

window.location.hash=string

2007-08-16 09:35
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
收藏
得分:0 

<html >
<head>
<title>无标题文档</title>
<script>
function updateinfo(whichbook)
{document.bookform.currbook.value=whickbook;
document.bookform.booktitle.value=this.title;
document.bookform.bookpublisher.value=this.publisher;
document.bookform.bookamount.value=this.amount;
}
function book(title,publisher,amount)
{this.title=title;
this.publisher=publisher;
this.amount=amount;
this.updateinfo=updateinfo;
}
</script>
</head>
<body>
<script>
var books=new Array();
books[0]=new book("语文","少年儿童出版社",10000);
books[1]=new book("数学","高教育出版社",120000);
books[2]=new book("计算机基础","清华出版社",50000);
books[3]=new book("WEB程序设计","电子工业出版",90000);
</script>
<h2 align=center>共有四本书可查看</h2>
<form name="bookform">
选中当前显示的书:<input type=button value='A书'onclick="books[0].updateinfo('A书')" >
<input type=button value="B书"onclick="books[1].updateinfo('B书')">
<input type=button value="C书"onclick="books[2].updateinfo('C书')">
<input type=button value="D书"onclick="books[3].updateinfo('D书')"><br><br>
当前名:<input type="text" value="A书" name="currbook"><br><br>
书名 : <input type="text" value="语文" name="booktitle"><br><br>
出版社:<input type="text" value="少年儿童出版社" name="bookpublisher"><br><br>
印数 : <input type="text" value="10000" name="bookamount">
</form>
</body>
</html>
运行这个程序时,按下B书,C书,D书这些按钮怎么没反应呀?
2007-08-16 12:19
jkll007123
Rank: 1
等 级:新手上路
威 望:1
帖 子:64
专家分:0
注 册:2007-7-8
收藏
得分:0 

直接用switch就好了


<html >
<head>
<title>无标题文档</title>
<script language="javascript">
function updateinfo(whichbook)
{
switch(whichbook)
{
case "a" : document.bookform.currbook.value="A书";
document.bookform.booktitle.value="语文";
document.bookform.bookpublisher.value="少年儿童出版社";
document.bookform.bookamount.value="10000";
break;
case "b" : document.bookform.currbook.value="B书";
document.bookform.booktitle.value="数学";
document.bookform.bookpublisher.value="高教育出版社";
document.bookform.bookamount.value="120000";
break;
case "c" : document.bookform.currbook.value="C书";
document.bookform.booktitle.value="计算机基础";
document.bookform.bookpublisher.value="清华出版社";
document.bookform.bookamount.value="50000";
break;
case "d" : document.bookform.currbook.value="D书";
document.bookform.booktitle.value="WEB程序设计";
document.bookform.bookpublisher.value="电子工业出版社";
document.bookform.bookamount.value="90000";
break;
default : break;
}
}


</script>
<!--
<script>
var books=new Array();
books[0]=new book("语文","少年儿童出版社",10000);
books[1]=new book("数学","高教育出版社",120000);
books[2]=new book("计算机基础","清华出版社",50000);
books[3]=new book("WEB程序设计","电子工业出版",90000);
</script>
-->
<h2 align=center>共有四本书可查看</h2>
<form name="bookform">
选中当前显示的书:<input type=button value='A书' onclick="updateinfo('a')" >
<input type=button value="B书" onclick="updateinfo('b')">
<input type=button value="C书" onclick="updateinfo('c')">
<input type=button value="D书" onclick="updateinfo('d')"><br><br>
当前名:<input type="text" value="A书" name="currbook"><br><br>
书名 : <input type="text" value="语文" name="booktitle"><br><br>
出版社:<input type="text" value="少年儿童出版社" name="bookpublisher"><br><br>
印数 : <input type="text" value="10000" name="bookamount">
</form>
</body>
</html>


習慣瞇醉,禧歡跟上帝窷兲,像变澀龙般虚伪,如气候那样善变.人脸背后流淌着恶魔的血,一路向前,猦猦癫癫.
2007-08-16 15:12
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:0 
以下是引用yqiong在2007-8-15 23:14:52的发言:
<html>
<head>
<title>无标题文档</title>
</head>
<body >
<script language="javascript">
var astr="开始";
var aname=astr.anchor("start");
document.write(aname);
</script>
</body>
</html>


怎么都没显示呀?效果应该和<a name ="star">开始</a>是一样的呀!

红色那句后面;用了中文字符


其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2007-08-16 20:15
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
收藏
得分:0 
以下是引用jkll007123在2007-8-16 15:12:04的发言:

直接用switch就好了


<html >
<head>
<title>无标题文档</title>
<script language="javascript">
function updateinfo(whichbook)
{
switch(whichbook)
{
case "a" : document.bookform.currbook.value="A书";
document.bookform.booktitle.value="语文";
document.bookform.bookpublisher.value="少年儿童出版社";
document.bookform.bookamount.value="10000";
break;
case "b" : document.bookform.currbook.value="B书";
document.bookform.booktitle.value="数学";
document.bookform.bookpublisher.value="高教育出版社";
document.bookform.bookamount.value="120000";
break;
case "c" : document.bookform.currbook.value="C书";
document.bookform.booktitle.value="计算机基础";
document.bookform.bookpublisher.value="清华出版社";
document.bookform.bookamount.value="50000";
break;
case "d" : document.bookform.currbook.value="D书";
document.bookform.booktitle.value="WEB程序设计";
document.bookform.bookpublisher.value="电子工业出版社";
document.bookform.bookamount.value="90000";
break;
default : break;
}
}


</script>
<!--
<script>
var books=new Array();
books[0]=new book("语文","少年儿童出版社",10000);
books[1]=new book("数学","高教育出版社",120000);
books[2]=new book("计算机基础","清华出版社",50000);
books[3]=new book("WEB程序设计","电子工业出版",90000);
</script>
-->
<h2 align=center>共有四本书可查看</h2>
<form name="bookform">
选中当前显示的书:<input type=button value='A书' onclick="updateinfo('a')" >
<input type=button value="B书" onclick="updateinfo('b')">
<input type=button value="C书" onclick="updateinfo('c')">
<input type=button value="D书" onclick="updateinfo('d')"><br><br>
当前名:<input type="text" value="A书" name="currbook"><br><br>
书名 : <input type="text" value="语文" name="booktitle"><br><br>
出版社:<input type="text" value="少年儿童出版社" name="bookpublisher"><br><br>
印数 : <input type="text" value="10000" name="bookamount">
</form>
</body>
</html>

谢谢,但能帮我找找我写的程序出错的原因吗?

2007-08-17 18:22
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
收藏
得分:0 
以下是引用yqiong在2007-8-16 12:19:44的发言:

<html >
<head>
<title>无标题文档</title>
<script>
function updateinfo(whichbook)
{document.bookform.currbook.value=whickbook;
document.bookform.booktitle.value=this.title;
document.bookform.bookpublisher.value=this.publisher;
document.bookform.bookamount.value=this.amount;
}
function book(title,publisher,amount)
{this.title=title;
this.publisher=publisher;
this.amount=amount;
this.updateinfo=updateinfo;
}
</script>
</head>
<body>
<script>
var books=new Array();
books[0]=new book("语文","少年儿童出版社",10000);
books[1]=new book("数学","高教育出版社",120000);
books[2]=new book("计算机基础","清华出版社",50000);
books[3]=new book("WEB程序设计","电子工业出版",90000);
</script>
<h2 align=center>共有四本书可查看</h2>
<form name="bookform">
选中当前显示的书:<input type=button value='A书'onclick="books[0].updateinfo('A书')" >
<input type=button value="B书"onclick="books[1].updateinfo('B书')">
<input type=button value="C书"onclick="books[2].updateinfo('C书')">
<input type=button value="D书"onclick="books[3].updateinfo('D书')"><br><br>
当前名:<input type="text" value="A书" name="currbook"><br><br>
书名 : <input type="text" value="语文" name="booktitle"><br><br>
出版社:<input type="text" value="少年儿童出版社" name="bookpublisher"><br><br>
印数 : <input type="text" value="10000" name="bookamount">
</form>
</body>
</html>
运行这个程序时,无错误,但按下A书,B书,C书,D书这些按钮怎么没反应呀?
2007-08-17 23:02
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
收藏
得分:0 
<html >
<head>
<title>无标题文档</title>
<script>
function book(title,publisher,amount)
{this.title=title;
this.publisher=publisher;
this.amount=amount;
this.updateinfo=function (whickbook)
{document.bookform.currbook.value=whickbook;
document.bookform.booktitle.value=this.title;
document.bookform.bookpublisher.value=this.publisher;
document.bookform.bookamount.value=this.amount;
}
}
</script>
</head>
<body>
<script>
var books=new Array();
books.length = 4;
books[0]=new book("语文","少年儿童出版社",10000);
books[1]=new book("数学","高教育出版社",120000);
books[2]=new book("计算机基础","清华出版社",50000);
books[3]=new book("WEB程序设计","电子工业出版",90000);
</script>
<h2 align=center>共有四本书可查看</h2>
<form name="bookform">
选中当前显示的书:<input type=button value='A书'onclick="books[0].updateinfo('A书')" >
<input type=button value="B书"onclick="books[1].updateinfo('B书')">
<input type=button value="C书"onclick="books[2].updateinfo('C书')">
<input type=button value="D书"onclick="books[3].updateinfo('D书')"><br><br>
当前名:<input type="text" value="A书" name="currbook"><br><br>
书名 : <input type="text" value="语文" name="booktitle"><br><br>
出版社:<input type="text" value="少年儿童出版社" name="bookpublisher"><br><br>
印数 : <input type="text" value="10000" name="bookamount">
</form>
</body>
</html>

IT618资讯网 提供服务端开发,前端开发,网页特效,热门开源系统研究,软件下载,站长建站,淘宝开店等学习资料.
2007-08-23 10:50
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
收藏
得分:0 
<html >
<head>
<title>无标题文档</title>
<script>
function updateinfo(whichbook)
{document.bookform.currbook.value=whickbook;
document.bookform.booktitle.value=this.title;
document.bookform.bookpublisher.value=this.publisher;
document.bookform.bookamount.value=this.amount;
}
function book(title,publisher,amount)
{this.title=title;
this.publisher=publisher;
this.amount=amount;
this.updateinfo=updateinfo;
}
</script>
</head>
<body>
<script>
var books=new Array();
books[0]=new book("语文","少年儿童出版社",10000);
books[1]=new book("数学","高教育出版社",120000);
books[2]=new book("计算机基础","清华出版社",50000);
books[3]=new book("WEB程序设计","电子工业出版",90000);
</script>
<h2 align=center>共有四本书可查看</h2>
<form name="bookform">
选中当前显示的书:<input type=button value='A书'onclick="books[0].updateinfo('A书'" >
<input type=button value="B书"onclick="books[1].updateinfo('B书'">
<input type=button value="C书"onclick="books[2].updateinfo('C书'">
<input type=button value="D书"onclick="books[3].updateinfo('D书'"><br><br>
当前名:<input type="text" value="A书" name="currbook"><br><br>
书名 : <input type="text" value="语文" name="booktitle"><br><br>
出版社:<input type="text" value="少年儿童出版社" name="bookpublisher"><br><br>
印数 : <input type="text" value="10000" name="bookamount">
</form>
</body>

IT618资讯网 提供服务端开发,前端开发,网页特效,热门开源系统研究,软件下载,站长建站,淘宝开店等学习资料.
2007-08-23 11:21
快速回复:特郁闷,刚学javascript,照书上去上机实践老出问题,怎么没结果显示? ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033246 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved