This is my Form:
<form id="locationsearch">
<label for="locationsearch">Location:</label>
<input type="search" name="locationsearch" id="searchValue"/>
</form>
I wish to get the value of the search input .
Altough I can access the search input's value like this:
const locationSearch = document.getElementById("locationsearch");
locationSearch.onsubmit = function (e) {
const searchValue = document.getElementById("searchValue");
console.log("search value", searchValue.value);
e.preventDefault();
};
But Can we access it using the 'e' parameter? For e.g I tried this which is not working:
const locationSearch = document.getElementById("locationsearch");
locationSearch.onsubmit = function (e) {
console.log("search value", e.target.input['search'].value);
e.preventDefault();
};
Does this work in react only?