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

    Executing script.

    In my admin area I have a textbox and a button to delete(truncate) a certain table in my db. There is only one table that needs clearing so the admin has to type in the table name every time (room for errors). I want a single button to do this (easy). So now I want to add some javascript (ajax) so that it simply has a message saying 'Table cleared'.

    I've written the script page and the php page that truncates the table but...

    it appears that because I have this line

    <script src="truncate.js" language="javascript"></script>
    the script runs and truncates the table as soon as the page loads, which I don't want.

    How can I stop the script from running until the button is clicked?

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Cebu City, Philippines
    Thanked 372 Times in 365 Posts
    Check your code. Ensure to remove traces of onload event, and replace it with onclick instead.

    If nothing works, please show us the code as well as the button that will trigger the function.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn


    Posting Permissions

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