0

Okay i have no idea why my second button isn't working. It seems straight forward but for some reason it is not working. The "Reset" button does not appear to be calling the clear() function.

Here is the HTML. I have two buttons that interact with a database. The first one, "Update", is to filter the search results. And the second, "Reset", is to reload the page. Right now I'm just trying to get minimal functionality out of the "Reset" button.

Here is the HTML:

 <script src = "filter.js" type="text/javascript"></script>
 ...
 <input type = "button" value = "Update" onclick = "filter(...);">
 <input type = "button" value = "Reset" onclick = "clear();">

And then the javascript in filter.js:

function filter(...) {
    ...
}

function clear() {
    alert("Alert");
}
1

3 Answers 3

1

Seems like clear is a reserved word. Try myClear for example:

<input type = "button" value = "Reset" onclick = "myClear();">
function myClear() {
    alert("Alert");
}

Working example: http://jsfiddle.net/s8nrd/

Sign up to request clarification or add additional context in comments.

Comments

0

The reason is because clear is a reserved word, just change your functions name to "Clear":

 <input type = "button" value = "Reset" onclick = "Clear();">

function Clear() {
    alert("Alert");
} 

Comments

0

I believe that clear() can be referenced as Document.clear() Try to name your function differently and post result.

Also do you get any error output when you click you input ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.