Page 1 of 1

how to call javascript after form post ?

Posted: Wed Aug 31, 2011 5:54 am
by uniojnqoifazy
hi all,
i want connect DB and get value from DB, then call javascript function , that's mean i want to send form data first
but form will be onsubmit first then send form data,
please someone else can tell me how to fix ???

Code: Select all

<script>
function excuteApplet()
	{
	    document.getElementById('myapplet').go();
             return true;
	}
</script>
<?
     if($_POST["submit"]=="Test")
		{	
			 require_once("DB_config.php");
    			  require_once("DB_class.php");
    			 $db = new DB;
       			$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
			$db->query("select ID,valueA, valueB from customer ;");
      		      while($row = $db->fetch_array())
     		         {
		 		$valueA= $row['valueA'];
		 		$valueB= $row['valueB'];
			        $ID= $row['ID'];
                                 $sql = "update customer set paid=1 where ID = '".$ID."'";
				$result = $db->update($sql);
				  $value= $valueA;
					if($total>30)
					{
						$value= trim($valueA);
	    			        }
         		               else 
				         {
					      $value= trim($valueB);
					}
		              }  //end while
               } //end if
 	?>
                   <applet id="myapplet" code="myapplet.class" name="myapplet" width="0" height="0" >
			      <PARAM NAME=customer VALUE=<? echo $value?>>   //get the value from dB , when form data have been send.....but how to do ????
	    	    </applet>

                    <form action=""  name="form1" onsubmit="return excuteApplet()" method="post">  //it's will be onsubmit first then send form data, but that's not i want....
                     <input  name="btn" type="submit" value="Test" id="Test"   >
                    </form>