I have javascript working in similar pages, but for some reason this one page does not load the JS at all. It's not that the code isn't working (it's just a few lines), but on my code debugger (using chromes "inspect element" feature) the javacsript isn't even registered as a script. I suppose there is some issue in where I am placing it.
I have a header included at the top, then put the script immediately, as follows:
<?
/* Include Files *********************/
require_once("common/header.php");
/*************************************/
?>
<script language="JavaScript" type="text/javascript">
ClearSearch(){
document.getElementById('search_q').value = '';
}
</script>
Lower in the page, I have a button that calls this function onclick:
<input type="submit" name="submit_search" value="Show All" onclick="javascript:ClearSearch();">
When I click the button, not only is the text box not cleared, but the javascript doesn't seem to run at all. It's as if the script isn't being detected. Any ideas?
Missing function
before your function declaration.
function ClearSearch(){
document.getElementById('search_q').value = '';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With