how to excute applet via the onSubmit event of the form ?

Discussion in 'JavaScript' started by uniojnqoifazy, Aug 30, 2011.

  1. #1
    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):
     
    uniojnqoifazy, Aug 30, 2011 IP
  2. MarPlo

    MarPlo Member

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    48
    #2
    Hy,
    Try add the onsubmit attribute into the <form> tag:
    <form action="" method="post" name="form1" onsubmit="return excuteApplet();">
    Code (markup):
     
    MarPlo, Aug 30, 2011 IP
  3. uniojnqoifazy

    uniojnqoifazy Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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):
     
    uniojnqoifazy, Aug 30, 2011 IP
  4. MarPlo

    MarPlo Member

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    48
    #4
    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.
     
    MarPlo, Aug 30, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    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.
     
    Rukbat, Aug 31, 2011 IP