Page 1 of 1

onclick event of button

Posted: Fri Aug 14, 2009 3:58 am
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.

Re: onclick event of button

Posted: Tue Aug 18, 2009 3:34 am
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

Re: onclick event of button

Posted: Tue Aug 18, 2009 10:26 am
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.