我在JavaScript中的copyaddress不是';行不通

我在JavaScript中的copyaddress不是';行不通,javascript,html,css,Javascript,Html,Css,我正试图让它与我的html一起工作。我正在将外部js和css添加到我的html中。我已经全部连接到我的html文件中。为什么我的文案地址不起作用?不太清楚我为什么会有这个问题。。。是我的html还是javascript语法不正确 <!DOCTYPE html> <html> <head> <title>Payment Form</title> <link rel="stylesheet" type="text/css" hr

我正试图让它与我的html一起工作。我正在将外部js和css添加到我的html中。我已经全部连接到我的html文件中。为什么我的文案地址不起作用?不太清楚我为什么会有这个问题。。。是我的html还是javascript语法不正确

   <!DOCTYPE html>
<html>
<head>
<title>Payment Form</title>
<link rel="stylesheet" type="text/css" href="style1.css">
</head>
<body>
<script src="java12.js"></script>
<hr>
<h1>Your Information</h1>
<br>
<form id="myForms">
  First name:<br>
  <input type="text" id="firstname">
  <br>
  <br>
  Middle Initial:<br>
  <input type="text"  id="middlename">
  <br>
  <br>
  Last name:<br>
  <input type="text" id="lastname">
  <br>
  <br>
  Address:<br>
  <input type="text"  id="myaddress">
  <br>
  <br>
  City:<br>
  <input type="text"  id="city">
  <br>
  <br>
   State:<br> 
        <select id = "state">
        <option value = "1">Alabama</option>
        <option value = "2">New York</option>
        <option value = "3">Florida</option>
        <option value = "4">California</option>
        </select><br><br>

    Zipcode:<br>
    <input type="text" name="zipcode">
    <br>
    <br>
    Phone: <br>
    <input type="text" name="Phone">
    <br>
    <br>
    <input onclick="copyaddress()" type="checkbox" id="myCheck">
     Billing Address the same as above



<h2>Billing Information</h2>
    Billing Address:<br>
  <input onclick="copy()" type="text" id="myCheck"><br>
  <br>
  <br>
    Billing City:<br>
  <input type="text" name="City">
  <br>
  <br>
    State:<br> 

             <select id="myList">
               <option value = "1">Alabama</option>
               <option value = "2">New York</option>
               <option value = "3">Florida</option>
               <option value = "4">California</option>
             </select><br><br>

    Zipcode:<br>
    <input type="text" id="zip">
    <br>
    <br>
    Phone: <br>
    <input type="text" id="Phone">
    <br>
    <br>
<hr>
<button onclick="OrderSubmitted()">
Submit</button>
</form>
</body>
</html>

您已经注释掉了几乎所有的代码
您应该取消对JavaScript代码的注释,以产生以下结果:

函数copyaddress(){
//从myaddress复制到billingaddress
document.forms[“myForms”][“myaddress”].value=
document.forms[“myForms”][“billingaddress”]。值;
警告(“未选中复选框!”);
}
函数OrderSubmitted(){
//检查firstname是否为空
var x=document.forms[“myForms”][“firstname”].value;
如果(x==“”){
警告(“必须填写姓名”);
返回false;
}
//检查lastname是否为空
var x=document.forms[“myForms”][“lastname”].value;
如果(x==“”){
警告(“必须填写姓氏”);
返回false;
}
警报(“订单已提交!”);

}
我删除了评论并修复了>但是我的副本地址仍然不起作用
function copyaddress() {
    // copy from myaddress to billingaddress
    document.forms["myForms"]["myaddress"].value =
    document.forms["myForms"]["billingaddress"].value;


    alert("checkbox not checked!");
}
function OrderSubmitted() {
    // check if firstname is blank
    var x = document.forms["myForms"]["firstname"].value;
if (x == "") {
        alert("First name must be filled out");
        return false;
    }
    // check if lastname is blank
    var x = document.forms["myForms"]["lastname"].value;
    if (x == "") {
        alert("Last name must be filled out");
        return false;
    }

    // check if middlename is blank
    var x = document.forms["myForms"]["middlename"].value;
if (x == "") {
        alert("Middle name must be filled out");
        return false;
    }

    // check if myaddress is blank
    var x = document.forms["myForms"]["myaddress"].value;
if (x == "") {
        alert("Address name must be filled out");
        return false;
    }

    // check if city is blank
    var x = document.forms["myForms"]["city"].value;
if (x == "") {
        alert("City name must be filled out");
        return false;
    }
    // check if zipcode is blank
    var x = document.forms["myForms"]["zipcode"].value;
if (x == "") {
        alert(" Zipcode must be filled out");
        return false;
    } 
    alert("Order Submitted!") ;
    }