Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Execute a script when a user clicks the button

    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?

    Thanks,
    Praveen

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    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?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    <script
    type="text/javascript"
    src="http://gdata.youtube.com/feeds/api/videos?q=puppy&alt=json-in-script&callback=showMyVideos2&max-results=30&format=5">
    </script>

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •