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");
}
asked Apr 25, 2014 at 19:56
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/

answered Apr 25, 2014 at 19:59
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");
} 
answered Apr 25, 2014 at 19:59

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 ?

answered Apr 25, 2014 at 19:59

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.