To get the value of an input using JavaScript, use document.getElementById('yourInputId').value to retrieve the input's value by its ID.
You can get the value of an input field in JavaScript using the value property of the input element. Here's an example:
html
<input type="text" id="myInput">
<button onclick="getValue()">Get Value</button>
<script>
function getValue() {
var inputValue = document.getElementById("myInput").value;
alert("The input value is: " + inputValue);
}
</script>
In this example, the JavaScript function getValue() retrieves the value of the input field with the ID "myInput" using document.getElementById("myInput").value and displays it in an alert box.