js如何获取checkbox的name属性

  时间:2017-03-22
本文章向大家介绍javascript如何获取checkbox的name属性值,需要的朋友可以参考一下。

js如何获取checkbox的name属性:

<html>
    <form name="orderForm">
      <input type="checkbox" name="V6">V6<br>
      <input type="checkbox" name="V8">V8<hr>
      <input type="button" value="Submit Order" name="orderButton" onClick="submitOrder()">
    </form>
    <script language="JavaScript">
    function submitOrder()
    {
      var alertString = String("You have selected a ");

      if(document.orderForm.V6.checked == true)
        alertString += document.orderForm.V6.name;  
      else
        alertString += document.orderForm.V8.name;  
      alertString += " truck.";
      alert(alertString);
    }
    </script>
</html>

原文地址:http://www.manongjc.com/article/1815.html