<?php

if(isset($_GET['field1']) && $_GET['field1'] == "31")
		{
			echo "lklmklmklml";
		
		}

?>




<form id="form1" name="form1" action = "#"  method="get"> 
    Field 1: <input id="field1" type="text" class="required" />
</form>

<div>
    <input id="btn" type="button" value="Validate" />
</div>
<div>
    <input id="dialogbtn" type="button" value="Open Dialog" />
</div>

<div id="dialog-form" title="Create new user">
  <form id="form2">
    <input type="hidden" name="cached" id="cached" value="" />
  
    <label for="name">Name</label>
    <input type="text" name="name" id="name" required="true" />
      <br/>
      <label for="email">Email</label>
    <input type="text" name="email" id="email" required="true" email="true"/>
    <br/>
      <label for="password">Password</label>
    <input type="password" name="password" id="password"/>
  
  </form>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
 
 
<script>

	$(function() {
    //simple example 1
    //click event for first button 
    $('#btn').click(function() {
	alert("plouf");
        
		//$("#field1").val("azer");
		//$("#form1").submit();
		//$("#form1").valid(); //validate form 1
		//location.reload();
		

		
		$("form1").submit(function() {
	       
				//	var  formData = "name=ravi&age=31";  //Name value Pair
				// var formData = {name:"ravi",age:"31"}; //Array 
			var  formData = "field1=31"; 
	        $.ajax({
	            type: "GET",
	            url: "formulaire.php",
	            data: formData
	          
	            });
	       
	    });
		
		
    });
    
    //example to validate inside a dialog box
    
    //dialogopen button click event
    $('#dialogbtn').click(function() {
	alert("plouf");
        $( "#dialog-form" ).dialog( "open" );
      });
    
    //code for dialog
    $( "#dialog-form" ).dialog({
      autoOpen: false,
      height: 300,
      width: 350,
      modal: true,
      buttons: {
        "Save": function() { //on click of save button of dialog
            if($('#form2').valid()){  //call valid for form2 and show the errors
               alert('submit form');  //only if the form is valid submit the form
                $( this ).dialog( "close" );
				
			//	$('#form1').submit();
				
            }
        },
        Cancel: function() {
          $( this ).dialog( "close" );
        }
      }
      
    });
});

</script>



