1

i am very beginner to php,html and web development.Now iam learning php. And i have a doubt which is exactly same as how to check if input type button is pressed in php?

but i couldn't find any appropriate answers there.Please see the above link... Actually form submission is done by using Java script, that's why he have something like this in button's onclick="send(this.form)" ...And this button type is not 'submit'but it is 'button' itself and i tried one of the answer that i found there Using print_r($_POST) to print all Submitted values..But i couldn't find my button there..

My html code

<Form action="user_register.php" method="post">
 <input type="text" id="txtEmail" name="textEmail"/>
 <input type="button onclick=runjava() Name="Button"/>
</Form>

My Javascript

function runjava()
{
  ---
  ----Codes for validation and some animation
  document.forms.item(0).submit();
}

please help me regarding this

1
  • You should post the php processing the code and the javascript handling the button, then we can help Commented Jun 21, 2013 at 18:37

1 Answer 1

0

Yes, you can use jQuery/javascript to do this.

Generally, you should assign either an ID or a class to your input element to easily identify exactly which control fired the event.

Suppose you have this input button:

<input type="button" id="mybutt" value="Click Me">

To alert when button is clicked:

$(document).ready(function() {
    $('#mybutt').click(function() {
        alert('it was pressed');
    });
});

The $(document).ready(function() { bit makes sure that the page (DOM) has loaded all elements first, before it allows the code to bind events to them, etc. This is important.

NOTE THAT before you use jQuery commands, you must first ensure the jQuery library has been referenced/loaded on your page. Most times we do this in the <head> tags, like so:

<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>

but it can be loaded any time before the jQuery code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.