错误:预期的对象 [英] Error: Object Expected

查看:57
本文介绍了错误:预期的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几天我一直试图解决这个错误......尝试了很多方法,但最终还是错误归还给我,它驱使我到最后!当它到达onblur事件时我一直收到这个错误!请给我一些建议吗?我们将不胜感激!!


[HTML]< html>

< head>< title>购物车< / title>

< script language =" javascript" type =" text / javascript">

<! - 隐藏旧版浏览器的javascript


功能CheckPen(数量){

if(qty =="")

alert(''Hello'')

}


function cart(已选择){


//数组用于在单个变量名中存储一组值

var price = new Array(1.5 ,1.2,1.6,0.5,0.8,2);

var prod = new Array(0,1,2,3,4,5);


//波纹管var用于保存计算数据的地方

var selectNo = selected.selectedIndex;

var selectName = selected.options [selectNo]。值;

var list = selected.options.size;

var choice = selected.options [selectNo] .selected;

var total = 0;

var line ="" ;;


if(selectNo!= - 1){

// line命令用于在新屏幕中显示

line ="< form>< table border = 2 bordercolor = blue cellspacing = 15 cellpadding = 10>" ;;

line = line +"< tr align =''center''>< th colspan = 4>< font size =''5''>购买产品"

line = line +"< tr>< td align = center>固定< td align = center>价格< td align = center> ;数量< td align = center>价格 


for(var i = 0; i< list; ++ i){

choice = selected。 options [i] .selected;

if(choice == true){

itemName = selected.options [i] .value;

//在表格中显示所选项目及其价格

line = line +"< tr>< td>" + selectName;

line = line +"< td align = center> S $< input type = button name = priceLabel" + prod [i] +" value =" + price [i] +">" ;;

line = line +"< td>< input type = text size = 10 maxlength = 5 name = qty" + PROD [I] + QUOT; onblur =''CheckPen(qty" + prod [i] +" .value)''>" ;;

line = line +"< td>< input type = button value =计算名称= subTotal" + prod [i] +"的onclick =小计" + PROD [I] + QUOT;。价值= priceLabel" + PROD [I] + QUOT;。价值*数量" + PROD [I] + QUOT;。价值,total.value = total.value * 1 + subTotal" + pr od [i] +" .value * 1>" ;;

}

}

line = line + "< tr>< td>< td>< td>总计:" ;;

// bellow命令用于显示所选项目的总费用

line = line +"< td>< input type = text readonly size = 6 name = total value = 0>" ;;

line = line +"< / table>< / form>" ;;

line = line +"< / body>< / html>" ;;


document.writeln(line)

}

}


//结束隐藏javascript - >

< / script>

< / head>

< body>

< form name = list>

< table>

< tr>

< td align = center>< h2>< u>购物车< / u> ;&升t; / h2>

< tr>

< td>

< select name = product size = 6 multiple>

<选项名称=笔值="笔">笔< /选项>

<选项名称=铅笔值="铅笔">铅笔< /选项>

<选项名称=颜色值="彩色铅笔>>彩色铅笔< /选项>

<选项名称=橡皮擦值="橡皮擦" ;>橡皮擦< /选项>

<选项名称=标尺值="标尺">标尺< /选项>

<选项名称=高价值="荧光笔>>荧光笔< /选项>

< / select>

< tr>

< td>< ; input type =" button" value =" Add to Cart" onClick =" cart(list.product)">

< / table>

< / form>

< / body>

< / html> [/ HTML]

I had been trying to solve this error for the past days... tried a number of ways but still the error return to me eventually and its driving me to the very end!!! I keep getting this error when it reach the onblur event!!! Pls share some advice for me? All will be greatly appreciated!!

[HTML]<html>
<head><title>Shopping Cart</title>
<script language="javascript" type="text/javascript">
<!-- Hide javascript from older browsers

function CheckPen(qty){
if(qty=="")
alert(''Hello'')
}

function cart(selected) {

//Array is used to store a set of values in a single variable name
var price = new Array(1.5,1.2,1.6,0.5,0.8,2);
var prod = new Array(0,1,2,3,4,5);

//the bellow var is for the place to hold the data for the calculation
var selectNo = selected.selectedIndex;
var selectName = selected.options[selectNo].value;
var list = selected.options.size;
var choice = selected.options[selectNo].selected;
var total = 0;
var line = "";

if (selectNo !=-1) {
// line command is for tob display in new screen
line = "<form><table border=2 bordercolor=blue cellspacing=15 cellpadding=10>";
line = line + "<tr align=''center''><th colspan=4><font size=''5''>Purchase Products"
line = line + "<tr><td align=center>Stationary<td align=center>Price<td align=center>Quantity<td align=center>Price"

for(var i = 0;i<list;++i) {
choice = selected.options[i].selected;
if (choice == true) {
itemName = selected.options[i].value;
//display the the selected items aling with their price in a table
line = line + "<tr><td>"+selectName;
line = line + "<td align=center>S$<input type=button name=priceLabel"+prod[i]+" value="+price[i]+">";
line = line + "<td><input type=text size=10 maxlength=5 name=qty"+prod[i]+" onblur=''CheckPen(qty"+prod[i]+".value)''>";
line = line + "<td><input type=button value=Calculate name=subTotal"+prod[i]+" onclick=subTotal"+prod[i]+".value=priceLabel"+prod[i]+".value*qty"+prod[i]+".value,total.value=total.value*1+subTotal"+pr od[i]+".value*1>";
}
}
line = line + "<tr><td><td><td>Total:";
// bellow command is used to diplay the total cost of the items selected
line = line + "<td><input type=Text readonly size=6 name=total value=0>";
line = line + "</table></form>";
line = line + "</body></html>";

document.writeln(line)
}
}

// End hiding javascript-->
</script>
</head>
<body>
<form name=list>
<table>
<tr>
<td align=center><h2><u>Shopping Cart</u></h2>
<tr>
<td>
<select name=product size=6 multiple>
<option name=pen value="Pen">Pen</option>
<option name=pencil value="Pencil">Pencil</option>
<option name=colour value="Colour Pencil">Colour Pencil</option>
<option name=eraser value="Eraser">Eraser</option>
<option name=ruler value="Ruler">Ruler</option>
<option name=high value="Highlighter">Highlighter</option>
</select>
<tr>
<td><input type="button" value="Add To Cart" onClick="cart(list.product)">
</table>
</form>
</body>
</html>[/HTML]

推荐答案

< input type = button name = priceLabel" + prod [ I] + QUOT; value =" + price [i] +">" ;;

line = line +"< td>< input type = text size = 10 maxlength = 5 name = qty" + PROD [I] + QUOT; onblur =''CheckPen(qty" + prod [i] +" .value)''>" ;;

line = line +"< td>< input type = button value =计算名称= subTotal" + prod [i] +"的onclick =小计" + PROD [I] + QUOT;。价值= priceLabel" + PROD [I] + QUOT;。价值*数量" + PROD [I] + QUOT;。价值,total.value = total.value * 1 + subTotal" + pr od [i] +" .value * 1>" ;;

}

}

line = line + "< tr>< td>< td>< td>总计:" ;;

// bellow命令用于显示所选项目的总费用

line = line +"< td>< input type = text readonly size = 6 name = total value = 0>" ;;

line = line +"< / table>< / form>" ;;

line = line +"< / body>< / html>" ;;


document.writeln(line)

}

}


//结束隐藏javascript - >

< / script>

< / head>

< body>

< form name = list>

< table>

< tr>

< td align = center>< h2>< u>购物车< / u> ;&升t; / h2>

< tr>

< td>

< select name = product size = 6 multiple>

<选项名称=笔值="笔">笔< /选项>

<选项名称=铅笔值="铅笔">铅笔< /选项>

<选项名称=颜色值="彩色铅笔>>彩色铅笔< /选项>

<选项名称=橡皮擦值="橡皮擦" ;>橡皮擦< /选项>

<选项名称=标尺值="标尺">标尺< /选项>

<选项名称=高价值="荧光笔>>荧光笔< /选项>

< / select>

< tr>

< td>< ; input type =" button" value =" Add to Cart" onClick =" cart(list.product)">

< / table>

< / form>

< / body>

< / html> [/ HTML]
<input type=button name=priceLabel"+prod[i]+" value="+price[i]+">";
line = line + "<td><input type=text size=10 maxlength=5 name=qty"+prod[i]+" onblur=''CheckPen(qty"+prod[i]+".value)''>";
line = line + "<td><input type=button value=Calculate name=subTotal"+prod[i]+" onclick=subTotal"+prod[i]+".value=priceLabel"+prod[i]+".value*qty"+prod[i]+".value,total.value=total.value*1+subTotal"+pr od[i]+".value*1>";
}
}
line = line + "<tr><td><td><td>Total:";
// bellow command is used to diplay the total cost of the items selected
line = line + "<td><input type=Text readonly size=6 name=total value=0>";
line = line + "</table></form>";
line = line + "</body></html>";

document.writeln(line)
}
}

// End hiding javascript-->
</script>
</head>
<body>
<form name=list>
<table>
<tr>
<td align=center><h2><u>Shopping Cart</u></h2>
<tr>
<td>
<select name=product size=6 multiple>
<option name=pen value="Pen">Pen</option>
<option name=pencil value="Pencil">Pencil</option>
<option name=colour value="Colour Pencil">Colour Pencil</option>
<option name=eraser value="Eraser">Eraser</option>
<option name=ruler value="Ruler">Ruler</option>
<option name=high value="Highlighter">Highlighter</option>
</select>
<tr>
<td><input type="button" value="Add To Cart" onClick="cart(list.product)">
</table>
</form>
</body>
</html>[/HTML]


展开 | 选择 | 换行 | 行号


展开 | 选择 | Wrap | 行号


这篇关于错误:预期的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆