Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML复选框返回值?_Javascript_Html_Checkbox - Fatal编程技术网

Javascript HTML复选框返回值?

Javascript HTML复选框返回值?,javascript,html,checkbox,Javascript,Html,Checkbox,下面是我的代码,我试图让它显示订单的结果,但是我无法让它显示,我相信checkbox的返回值可能不是true,所以我尝试使用var checkedt5=$t5.is':checked';但是我遇到了错误,onclick-on-order无法工作。我相信函数中有错误 <html> <head> <title>Form </title> <script LANGUAGE="JavaScript"> <!-- hide fr

下面是我的代码,我试图让它显示订单的结果,但是我无法让它显示,我相信checkbox的返回值可能不是true,所以我尝试使用var checkedt5=$t5.is':checked';但是我遇到了错误,onclick-on-order无法工作。我相信函数中有错误

<html>

<head>
    <title>Form </title>

<script LANGUAGE="JavaScript">
<!-- hide from uneducated browsers
function Order()
{
  var size = document.getElementById("pizzasize").value
  var crust = document.getElementById("pizzacrust").value
  var t1 = document.getElementById("t1").value
  var t2 = document.getElementById("t2").value
  var t3 = document.getElementById("t3").value
  var t4 = document.getElementById("t4").value
  var t5 = document.getElementById("t5").value
  var checkedt1 = $("t1").is(':checked');
  var checkedt2 = $("t2").is(':checked');
  var checkedt3 = $("t3").is(':checked');
  var checkedt4 = $("t4").is(':checked');
  var checkedt5 = $("t5").is(':checked');



    document.write("<p>")
document.write("Your order is in process <br /> ")
       document.write("Pizza Size = " + size + "<br />")
       document.write("Pizza Crust = " + crust + "<br />")
 if (checkedt1 == true)
 {
 document.write("Toppings = " + t1 + "<br />")
 }
 if (checkedt2 == true)
 {
 document.write("Toppings = " + t2 + "<br />")
 }
     if (checkedt3 == true)
     {
 document.write("Toppings = " + t3 + "<br />")
 }
     if (checkedt4 == true)
     {
 document.write("Toppings = " + t4 + "<br />")
 }
     if (checkedt5 == true)
     {
 document.write("Toppings = " + t5 + "<br />")
 }
     document.write("Your order will be delivered as soon as possible")

   return ""
   }

    // end hiding from uneducated browsers  -->
    </script>

  <style TYPE="text/css">
  body 
  {
  background-color: lightsteelblue;
  }
  </style>
  </head>

  <body>

  <h1>Mateo's Pizzeria</h1>
  <form>
     <b>Pizza Size</b>: 
     <select name="pizzasize" id="pizzasize">
    <option value="" disabled="disabled" selected="selected">Please select a              size</option>
    <option value="personal">Personal</option>
    <option value="small">Small</option>
    <option value="medium">Medium</option>
    <option value="large">Large</option>
    <option value="x-large">X-Large</option>
    <option value="omg">OMG</option>
  </select>
     <p>
     <b>Pizza Crust</b>: 
     <select name="pizzacrust" id="pizzacrust">
   <option value="" disabled="disabled" selected="selected">Please select a crust type</option>
    <option value="thin">Thin</option>
    <option value="thick">Thick</option>
    <option value="sicilian">Sicilian</option>
  </select>
     <p>

 <b>Pizza Toppings</b>:
     <br>
      <input type="checkbox" name="toppings" id="t1" value="pepperoni">Pepperoni<br>
      <input type="checkbox" name="toppings" id="t2" value="sausage">Sausage<br>
<input type="checkbox" name="toppings" id="t3" value="mushrooms">Mushrooms<br>
<input type="checkbox" name="toppings" id="t4" value="black-olives">Block              Olives<br>
<input type="checkbox" name="toppings" id="t5" value="pineapple">Pineapple<br>


  </select>
     <p>
     <b>Confirmed Order</b>: <output TYPE="text" NAME="output" ID="outputID" SIZE="50"             WIDTH="50" />
     </p><p>
     <input TYPE="button" VALUE="Confirm Order" onClick="Order()" />
     </p><p>
     <!--// <input TYPE="button" VALUE="Process Input 2" onClick="newProcess()" /> -->
  </p></form>

  </body>
  </html>
你错过了比赛


我已经按要求添加了每个元素,但是仍然无法运行it@user2951224在页面中包括jQuery。
var checkedt1 = $("#t1").is(':checked');
var checkedt2 = $("#t2").is(':checked');
var checkedt3 = $("#t3").is(':checked');
var checkedt4 = $("#t4").is(':checked');
var checkedt5 = $("#t5").is(':checked');