onclick event of button

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
skylines
Forum Newbie
Posts: 8
Joined: Tue Jul 28, 2009 2:45 am

onclick event of button

Post by skylines »

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.
User avatar
mrvijayakumar
Forum Commoner
Posts: 58
Joined: Tue Aug 18, 2009 12:39 am
Location: Chennai city, India
Contact:

Re: onclick event of button

Post by mrvijayakumar »

Hi,
You can't call php files on any events. This issue can be solved by using simple ajax code(Don't get tensed, very simple and compatible to use). I hope, below url will guide u to make onclick, onkeyup etc.., events to call php files. Follow below URL, http://www.vijayakumar.org/index.php/20 ... -websites/

Reply me when u got result or not compatible with code. I will give u deep explanation.

Cheers,
Vijaya Kumar S,
Web Developer,
+91 9952838699,
http://www.vijayakumar.org
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: onclick event of button

Post by pickle »

You need to put "login.php" in the "action" attribute of your <form> tag. Then, when your submit button is clicked, the form will be submitted to login.php.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply