OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Button onclick not calling function

  • Thread starter Thread starter user3642768
  • Start date Start date
U

user3642768

Guest
My button code looks like this:

Code:
<button onclick="submitFunction()">Submit</button>

And my function code like this:

Code:
function submitFunction() {
    alert("example");
}

I've been looking online for an answer and tried a bunch of things, but nothing seems to work. I'm just putting the alert there to see if the function is being called at all. I'm using the following to link the files.

Code:
<script src="file.js"></script>

<p>My button code looks like this:</p>

<pre><code><button onclick="submitFunction()">Submit</button>
</code></pre>

<p>And my function code like this:</p>

<pre><code>function submitFunction() {
alert("example");
}
</code></pre>

<p>I've been looking online for an answer and tried a bunch of things, but nothing seems to work. I'm just putting the alert there to see if the function is being called at all.
I'm using the following to link the files. </p>

<pre><code><script src="file.js"></script>
</code></pre>
 
Top