一个关于javascript问题,请各位高手指教一下!!!
<html><head><title>javascript变量命名实例</title><scriptlanguage="javascript"><!--/*全局变量,大写...
<html>
<head>
<title>javascript变量命名实例</title>
<script language="javascript">
<!--
/*全局变量,大写*/
var DISCOUNT = 0.7;//折扣
//计算书本折扣后价格,并弹出提示
function getPrice(){
/*局部变量,使用"book_"前缀,为了表明是全局变量,前面同哟再增加“_”前缀*/>
var _book_name = document.myform.bookname.value;
var _book_author = document.myform.bookauthor.value;
var _book_price = document.myform.bookprice.value;
/*局部变量,使用“_”前缀*/
var _price = _book_price * DISCOUNT;
var _alent ="这本书名为《"+_book_name+"》,"+_book_author+"编著的书,折扣后价格为"+_price;
alert(_alert);
}
//__>
</script>
</head>
<body>
<form name="myform">
价格:
<input type="text" name="bookprice" value="50"><br/>
书名:
<input type="text" name="bookname" value="Javascript入门教程"><br/>
作者:
<input type="bookauthor" value="小明"><br/>
<input type="button" onclick="getPrice()" value="计算折扣价">
</form>
</body>
</html>
为什么显示好多错误呢??? 展开
<head>
<title>javascript变量命名实例</title>
<script language="javascript">
<!--
/*全局变量,大写*/
var DISCOUNT = 0.7;//折扣
//计算书本折扣后价格,并弹出提示
function getPrice(){
/*局部变量,使用"book_"前缀,为了表明是全局变量,前面同哟再增加“_”前缀*/>
var _book_name = document.myform.bookname.value;
var _book_author = document.myform.bookauthor.value;
var _book_price = document.myform.bookprice.value;
/*局部变量,使用“_”前缀*/
var _price = _book_price * DISCOUNT;
var _alent ="这本书名为《"+_book_name+"》,"+_book_author+"编著的书,折扣后价格为"+_price;
alert(_alert);
}
//__>
</script>
</head>
<body>
<form name="myform">
价格:
<input type="text" name="bookprice" value="50"><br/>
书名:
<input type="text" name="bookname" value="Javascript入门教程"><br/>
作者:
<input type="bookauthor" value="小明"><br/>
<input type="button" onclick="getPrice()" value="计算折扣价">
</form>
</body>
</html>
为什么显示好多错误呢??? 展开
2011-06-26
展开全部
小错误太多,就不细说了,改好的,你自己对比着看看吧。
--------------------
<html>
<head>
<title>javascript变量命名实例</title>
<script type="text/javascript">
var DISCOUNT = 0.7;//折扣
//计算书本折扣后价格,并弹出提示
function getPrice(){
var _book_name = document.myform.bookname.value;
var _book_author = document.myform.bookauthor.value;
var _book_price = document.myform.bookprice.value;
var _price = Number(_book_price) * DISCOUNT;
//alert(_price);
var _alert ="这本书名为《"+_book_name+"》,"+_book_author+"编著的书,折扣后价格为"+_price;
alert(_alert);
}
</script>
</head>
<body>
<form name="myform">
价格:
<input type="text" name="bookprice" value="50"><br/>
书名:
<input type="text" name="bookname" value="Javascript入门教程"><br/>
作者:
<input type="text" name="bookauthor" value="小明"><br/>
<input type="button" onclick="getPrice()" value="计算折扣价">
</form>
</body>
</html>
--------------------
<html>
<head>
<title>javascript变量命名实例</title>
<script type="text/javascript">
var DISCOUNT = 0.7;//折扣
//计算书本折扣后价格,并弹出提示
function getPrice(){
var _book_name = document.myform.bookname.value;
var _book_author = document.myform.bookauthor.value;
var _book_price = document.myform.bookprice.value;
var _price = Number(_book_price) * DISCOUNT;
//alert(_price);
var _alert ="这本书名为《"+_book_name+"》,"+_book_author+"编著的书,折扣后价格为"+_price;
alert(_alert);
}
</script>
</head>
<body>
<form name="myform">
价格:
<input type="text" name="bookprice" value="50"><br/>
书名:
<input type="text" name="bookname" value="Javascript入门教程"><br/>
作者:
<input type="text" name="bookauthor" value="小明"><br/>
<input type="button" onclick="getPrice()" value="计算折扣价">
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询