带按钮的PHP表单

I have some experience in JAVA GUI programming and I want to achieve the same in a PHP form.

Situation: I want to have a php form with a submit button. When the button is pressed an ActionEvent should be called to update another part of the form.

How to implement such a feature with HTML,PHP,JAVASCRIPT ?

Load latest version of jQuery:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

HTML code:

<form>
 <button type="button" class="formLoader">Click button</button>
 <div id="formContentToLoad"></div>
</form>

jQuery code:

<script type="text/javascript">
$(function(){
  $(".formLoader").click(function(){
    $("#formContentToLoad").load("scriptToRun.php");
  });
});
</script>

Whatever markup you need to update in the form, can be put into scriptToRun.php

Use jQuery

Javascript

$(document).ready(function() {
    $(".myForm").submit(function() {
        $.ajax({
            type: "POST",
            url: "myForm.php",
            data: $(this).serialize(),
            success: function(response) {
                // todo...
                alert(response);
            }
        })
    })
});

Html

<form method="POST" class="myForm">
    <input type="text" id="a_field" name="a_field" placeholder="a field" />
    <input type="submit" value="Submit" />
</form>

PHP

<?php
if(isset($_POST)) {
    $a_field = $_POST["a_field"];
    // todo..
}

If you want to use PHP and HTML to submit a form try this:
HTML Form

<form action="" method="post">
   <input type="text" placeholder="Enter Name" name="name" />
   <input type="submit" name="sendFormBtn" />
</form>

PHP

<?php
  if(isset($_POST["sendFormBtn"]{
    $name = isset($_POST["name"]) ? $_POST["name"] : "Error Response Here";
    //More Validation Here
  }