Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72388

Onclick function does not work when doing function call

$
0
0

I have a button that does not call the function when the button is clicked. The onclick function can display an alert window but does not run the function call.

...
   <fieldset>
        <legend>Billing Information</legend>
        <label for="name2">Name:</label><br>
        <input type="text" id="name2" name="full_name"><br>
        <label for="zip2">Zip code:</label><br>
        <input type="text" id="zip2" name="zip_code">
   </fieldset>
   <button type="button" onclick="clear()">Verify</button>
...
<script>
    function clear() {
        document.getElementById("name1").value = "";
        document.getElementById("zip1").value = "";
        document.getElementById("name2").value = "";
        document.getElementById("zip2").value = "";
    }
...
</script>

So this works:

<button type="button" onclick="alert("Hello")">Verify</button>

But the function clear does not work. I don't see why this doesn't work.


Viewing all articles
Browse latest Browse all 72388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>