How can I get the value of an HTML form to pass to JavaScript?
Is this correct? My script takes two arguments one from textbox, one from the dropdown box.
JavaScript
x
14
14
1
<body>
2
<form name="valform" action="" method="POST">
3
4
Credit Card Validation: <input type="text" id="cctextboxid" name="cctextbox"><br/>
5
Card Type: <select name="cardtype" id="cardtypeid">
6
<option value="visa">Visa</option>
7
<option value="mastercard">MasterCard</option>
8
<option value="discover">Discover</option>
9
<option value="amex">Amex</option>
10
<option value="diners">Diners Club</option>
11
</select><br/>
12
<input type="button" name="submit" value="Verify Credit Card" onclick="isValidCreditCard(document.getElementById('cctextboxid').value,document.getElementById('cardtypeid').value)" />
13
</body>
14
Advertisement
Answer
HTML:
JavaScript
1
2
1
<input type="text" name="name" id="uniqueID" value="value" />
2
JS:
JavaScript
1
2
1
var nameValue = document.getElementById("uniqueID").value;
2