Hi,
I want to call a php script in onclick event of Button in HTML. I used the following code,
<input type="submit" name="button" value="button" onclick="login.php" />
when i click the button the page is not going to login.php and in apache i am getting an error "use of undefined constant login" .
In the input tag for attribute type i tried with both. type="button" and type="submit".
Really i have no idea what is the difference between button and submit for type attribute.
Can anyone pls help me out.
onclick event of a button
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: onclick event of a button
This should work for you:
Code: Select all
<input type="button" onclick="document.location='http://www.google.com/'">Re: onclick event of a button
hey, thanks. This worked for me.
- swhistlesoft
- Forum Newbie
- Posts: 9
- Joined: Fri Aug 14, 2009 10:53 pm
- Location: Ontario
Re: onclick event of a button
onClick is a client side event usually used with javascript. If you want a specific php script to be called using an onclick event, simply use:
as aceconcepts suggested. If you already understood my explanation from aceconcepts, then ignore this post 
Code: Select all
1. <input type="button" onclick="document.location='http://www.yourdomain.com/login.php'">