The search mechanism below is working perfectly if the search.png is clicked. Getting it to also work when the text cell is active and the Enter key is pressed has not worked.
If the text cell is empty it does complain, focus and stop. But if a string has been entered it fails. The alert displays the correct URL and if I copy and paste from the alert into the browser, it works as it should. It does get submitted by the Enter key, but it appears that it's not submitting the full URL, truncating it after the question mark.
Where is this going wrong?
<form action ="" class="form" onSubmit="srch();" id="dvcsearch">
<input type="search" placeholder="Search for a device by name" class="biginput" id="dvclist" size="25"/>
<img class="search-png" src="/images/graphics/search.png" onClick="srch();">
</form>
<script>
function srch() {
var p = document.getElementById('dvclist').value;
if (p == "") {alert("Please enter the device you're seeking");
document.getElementById('dvclist').focus();
return false;
}
else {
document.getElementById('dvcsearch').action = 'cgi-bin/mdvl.cgi?prcdrs~device~srch~'+p;
alert(document.getElementById("dvcsearch").action);
// return true;
document.getElementById("dvcsearch").submit();
}
}
</script>