nadji  
          
              
                July 7, 2012,  1:06pm
               
              1 
           
         
        
          Assalemou 3alaykom,
I’m newbie in Yii && PHP/Javascript. I want to run a Javascript function before submit my Form
Do some thing like that in Yii
<html>
<head>
<script>
function doThis()
{
alert("testing");
return true
}
</script>
</head>
<body>
<form action="test.php" onsubmit="return doThis()" method="post">
<input type=submit >
</form>
</body>
</html>
Any body can help me how to implement that in Yii ?
Many thanks ya ikhwan 
         
        
           
         
            
            
       
      
        
          
          
            abennouna  
          
              
                July 12, 2012,  7:11pm
               
              2 
           
         
        
          Wa 3alaykum assalam wa arra7ma
A good example lays in the "admin.php" view that is automatically generated by gii/giix:
<?php Yii::app()->clientScript->registerScript('someScript', "
$('#testForm').submit(function() {
    alert("testing");
});
");
?>
<form id="testForm" action="test.php" method="post">
    <input type=submit >
</form>
 
        
           
         
            
       
      
        
          
          
            Drini  
          
              
                July 24, 2012,  6:04pm
               
              3 
           
         
        
          Do it like this:
<html>
<head>
<script>
$("#myform").submit(function(event){
event.preventDefault();
doThis();
$("#myform").submit();
});
function doThis()
{
alert("testing");
return true
}
</script>
</head>
<body>
<form id="myform" action="test.php" method="post">
<input type=submit >
</form>
</body>
</html>
 
        
           
         
            
       
      
        
        
          Hi, try this code:
$('#form').on('beforeSubmit', function(e) {
   //your code
  return false;
}).on('submit', function(e){
    e.preventDefault();
});
 
        
           
         
            
       
      
        
          
          
            muaid  
          
              
                March 27, 2015,  3:05pm
               
              5 
           
         
        
          [rtl]
السلام عليكم،، بعض الاخوان لايجيد تحدث الانجليزية وقد تم تخصيص هذا المنتدي للمتحدثين باللغة العربية فالافضل لو نساعدهم ونشركم معنا في المنتدي لتتحقق الفائدة من هذا المنتدي العربي
لكم اجمل التحايا والشكر على اطروحاتكم ومشاركاتكم
[/rtl]