weixin_33716557 2017-05-24 08:56 采纳率: 0%
浏览 27

单选按钮ajax值

I have a problem with this code.

I want to know what type of value of my radiobutton but I got a "undefined" value on my alert, I don't understand why, can you please help me for this ?

Here is my script (and sorry for those french comments):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<script>

$( document ).ready(function() {
    // Cacher les champs de sondage au départ
    $('.divSondage').hide();
    $('.trDivSondage').hide();
    $('#radioSondage1').attr('checked','checked');
    // Au changement 'questionnaire sondage' oui ou non, on affiche les types de sondage

  $('input[name=radioSondage]:radio').on('change',function(){
        if($(this).val()==0){
            $('.divSondage').show();
        } else if($(this).val()==1){
            $('.divSondage').hide();
        }

  });

  // on remplit les champs avec les types de sondage
  var url3 = 'inc/ajax/getTypesSondage_tache.php';
  var parametres3 = {id_tache : <?php echo $thisTache->id_tac;?>, type_tac  
    : <?php echo $thisTache->type_tac;?>
  };

  var postAjax3 = $.post(url3,parametres3, function(data){
    $('#divRadioTypeSondage').append(data);
  });
});

// remplis le select avec la liste des user du client
var url1 = 'inc/ajax/getUserClient_tache_popup.php';
var parametres1 = {id_tache : <?php echo $thisTache->id_tac;?>, initiateur : <?php echo $thisTache->initiateur_tac;?>};

var postAjax1= $.post(url1, parametres1, function(data){
               $('#selectInitiateurSondage').append(data);

        });


            // Lorsque l'etat de la tache est sur fermé, on affiche la possibilité de choisir un questionnaire

            $('#etat_tac').on('change',function(){
              if($(this).val()==40){
                $('.divSondage').show();
                $('.trDivSondage').show();
                $('#radioSondage0').prop('checked',true);
                $('#radioSondage1').prop('checked',false);    
              }
              else{

                    $('.divSondage').hide();
                    $('.trDivSondage').hide();
                    $('#radioSondage0').prop('checked',false);
                    $('#radioSondage1').prop('checked',true);

                  }
              });

        function sondageAjax(pTache){

              if($('input[name=radioTypeSondage]:radio:checked').val()>0||$('input[name=radioSondage]:radio:checked').val()==0){

              if($('input[name=radioTypeSondage'+pTache+']:radio:checked').val()==0){
                      alert("Il faut choisir un type de sondage");
                      return false;
                    }

                  var url = 'inc/ajax/sondageFermeturePopup.php';
                  var pRadioSondage = $('input[name=radioSondage]:radio:checked').val();
                  var pTypeSondage = $('input[name=radioTypeSondage'+pTache+']:radio:checked').val();
                  alert(pTypeSondage);
                  var pDate = '<?php echo date('Y-m-d H:i:s');?>';
                  var pInitiateur = $('#selectInitiateurSondage').val();
                  var parametres = {initiateur : pInitiateur, type_sondage : pTypeSondage, radio_sondage : pRadioSondage, date : pDate, tache : pTache, id_user : <?php echo $_SESSION['id_user']?>};

                  var postAjax= $.post(url, parametres, function(data){
                   alert(data);
                  });
              }
            }
    </script>

Thanks you

  • 写回答

0条回答 默认 最新

    报告相同问题?