如何获得HTML表单的值以传递给JavaScript?
它是否正确?我的脚本有两个参数,一个来自文本框,一个来自下拉框。
<body> <form name="valform" action="" method="POST"> Credit Card Validation: <input type="text" id="cctextboxid" name="cctextbox"><br/> Card Type: <select name="cardtype" id="cardtypeid"> <option value="visa">Visa</option> <option value="mastercard">MasterCard</option> <option value="discover">Discover</option> <option value="amex">Amex</option> <option value="diners">Diners Club</option> </select><br/> <input type="button" name="submit" value="Verify Credit Card" onclick="isValidCreditCard(document.getElementById('cctextboxid').value,document.getElementById('cardtypeid').value)" /> </body>
HTML:
<input type="text" name="name" id="uniqueID" value="value" />
JS:
var nameValue = document.getElementById("uniqueID").value;