<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
 <script language="javascript"> function computer(name,hdspace,ram)
 {
  this.speed=name;
  this.hdspace=hdspace;
  this.ram=ram; }  function get_price(computer)
 {
 the_price=1000;
 if  (computer.speed=500 ) 
 the_price+=200;
 else 
 the_price+=100; if ( computer.hdspace=15 )
  the_price+=150;
  else 
  the_price+=75;  return the_price;
 
 } 
function price(){var work_computer=new computer(500,15,128);
 var  home_computer=new computer(450,10,64);
 var laptop_computer=new computer(350,7,32); work_computer_price=get_price(work_computer);
 home_computer_price=get_price(home_computer);
 laptop_computer=get_price(laptop_computer);document.write ("type"+"        "+"speed"+"       "+"hdspace"+"         "+"ram"+"<p>");
document.write("work_computer"+ "   "+work_computer.speed+"     "+work_computer.hdspace+"          "+workcoputer.ram+"<p>");
document.write("home_computer"+"    "+home_computer.speed+"     "+home_computer.hdspace+"          "+home_computer.ram+"<p>");
document.write("laptop_computer"+"     "+laptop_computer.speed+"     "+laptop_computer.hdspace+"          "+laptop_computer.ram);}  </script></HEAD><BODY>
<form>
<table>
<input type=button value=clickme onclick="price()">
 </table>
 </form></BODY>
</HTML>

解决方案 »

  1.   

    错误较多,主要是手误,改以下:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT=""><script language="javascript">
    function computer(speed,hdspace,ram) {
      this.speed=speed;
      this.hdspace=hdspace;
      this.ram=ram;
    }function get_price(computer) {
      the_price=1000;
      if(computer.speed==500 ) 
        the_price+=200;
      else 
        the_price+=100;
      if( computer.hdspace=15 )
        the_price+=150;
      else 
        the_price+=75;
      return the_price;
    }function price() {
      var work_computer=new computer(500,15,128);
      var home_computer=new computer(450,10,64);
      var laptop_computer=new computer(350,7,32);  work_computer_price=get_price(work_computer);
      home_computer_price=get_price(home_computer);
      laptop_computer=get_price(laptop_computer);  document.write("type"+"        "+"speed"+"       "+"hdspace"+"         "+"ram"+"<p>");
      document.write("work_computer"+ "   "+work_computer.speed+"     "+work_computer.hdspace+"          "+work_computer.ram+"<p>");
      document.write("home_computer"+"    "+home_computer.speed+"     "+home_computer.hdspace+"          "+home_computer.ram+"<p>");
      document.write("laptop_computer"+"     "+laptop_computer.speed+"     "+laptop_computer.hdspace+"          "+laptop_computer.ram);
    }</script></HEAD><BODY>
    <input type=button value=clickme onclick="price()">
    </BODY>
    </HTML>
      

  2.   

    都能显示呀!
    type speed hdspace ram
    work_computer 500 15 128home_computer 450 15 64laptop_computer undefined undefined undefined
      

  3.   

    在更正两处
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT=""><script language="javascript">
    function computer(speed,hdspace,ram) {
      this.speed=speed;
      this.hdspace=hdspace;
      this.ram=ram;
    }function get_price(computer) {
      the_price=1000;
      if(computer.speed==500 ) 
        the_price+=200;
      else 
        the_price+=100;
      if( computer.hdspace==15 )
        the_price+=150;
      else 
        the_price+=75;
      return the_price;
    }function price() {
      var work_computer=new computer(500,15,128);
      var home_computer=new computer(450,10,64);
      var laptop_computer=new computer(350,7,32);  work_computer_price=get_price(work_computer);
      home_computer_price=get_price(home_computer);
      laptop_computer_price=get_price(laptop_computer);  document.write("type"+"        "+"speed"+"       "+"hdspace"+"         "+"ram"+"<p>");
      document.write("work_computer"+ "   "+work_computer.speed+"     "+work_computer.hdspace+"          "+work_computer.ram+"<p>");
      document.write("home_computer"+"    "+home_computer.speed+"     "+home_computer.hdspace+"          "+home_computer.ram+"<p>");
      document.write("laptop_computer"+"     "+laptop_computer.speed+"     "+laptop_computer.hdspace+"          "+laptop_computer.ram);
    }</script></HEAD><BODY>
    <input type=button value=clickme onclick="price()">
    </BODY>
    </HTML>