View Full Version : Execute a script when a user clicks the button

12-29-2010, 01:27 AM
Hi Everyone,

I want to execute a script when the user clicks the button.

Currently in my html doc. i have the button declared.
<input type="button" id ="button" onclick='notEmpty() value="Play"/>

When the button is clicked, i execute the notEmpty() function and I want to execute a script inside the notEmpty(). How can i do this?


Old Pedant
12-29-2010, 01:38 AM
Ummm...notEmpty *IS* a script.

It must be a JavaScript function by that name.

I should note that you are missing an apostrophe there: You do onclick='notEmpty() and that's not legal. You *MUST* have the matching apostrophe: onclick='notEmpty()' though it would be better to use quote marks: onclick="notEmpty()"

Where is your code for notEmpty? What does it do? What do you want it to do?

12-29-2010, 01:46 AM
yes. u are right. i missed an apostrophe on my last post.

I want to implement the code below in my notEmpty() function. I want to implement the "src" inside the function.


Old Pedant
12-29-2010, 03:08 AM
Ahhh...now I see what you mean. I'll have to let somebody else answer. I know there are ways to invoke stuff like that dynamically, but it's not obvious how.