dimanche 21 février 2016

how to compare textedit with javascript before action submit on yii 1?

i want run javasript check function, here is my code :

 <script>
 function check(){
 var all_problem = parseInt(document.getElementById('all_problem').value);
 var problem_one = parseInt(document.getElementById('problem_one').value);
 var problem_two = parseInt(document.getElementById('problem_two').value);

  var join_problem = problem_one+problem_two;
  if (all_problem<join_problem){
     //submit button is not permit to upload data
   } else {

  // submit button permit to upload data
    }



   }

    </script>

and here is my submit button function :

<?php echo CHtml::submitButton($model->isNewRecord ? 'Simpan' : 'Simpan', array('name'=>'save')); ?>

my scenario is : if all problems 5, and join problems is 6 (all problems < join problems), action on submit button won't run. and if all problems 5 and join problems 4 (all problems > join problem), action submit button will run.

thanks for your response

Aucun commentaire:

Enregistrer un commentaire