View Full Version : Executing script.

01-20-2009, 11:14 AM
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?

01-20-2009, 11:20 AM
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.