hi all, i try to using onsubmit with javascript function called to excute applet, but still can't excute the applet , Can someone please help me ? <html> <body> <script> function excuteApplet() { document.getElementById('myapplet').go(); return true; } </script> <? if(isset($_POST["btn"])) { .............. ....................... } ?> <form action="" method="post" name="form1"><input name="btn" type="submit" value="Test" onSubmit="return excuteApplet();" ></form> </body> </html> Code (markup):
Hy, Try add the onsubmit attribute into the <form> tag: <form action="" method="post" name="form1" onsubmit="return excuteApplet();"> Code (markup):
MarPlo, thanks for your reply, now i can excute the applet, but i can get the value from php ,please see the comment in the code , how can i get the value to applet parameter ? 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 ;"); $result_num = $db->get_num_rows(); echo "<br />";*/ 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); } } } ?> <applet id="myapplet" code="myapplet.class" name="myapplet" width="0" height="0" > <PARAM NAME=customer VALUE=<? echo $value?>> [COLOR="#FF0000"] //I can't get the value ,please tell me how to get the value ??????[/COLOR] </applet> Code (markup):
Hy, I don't know how to work with <applet> and <param> tags. Try to add an ID in that <param> and then, in JS get the value with "document.getElementById('ID').value". Or add an <input type="hidden" value="your_value" id="ID" /> and get the vaalue from this input.
Remember, the PHP runs, creates the page (including the form) and sends it to the browser. The browser executes the Javascript when the user submits the form. We use AJAX to do what you're doing, sending data to a PHP file and getting back an answer. Read a tutorial or two on AJAX, then look at jQuery's ajax() function - it makes AJAX almost trivial.