2016-04-13 12 views
0

selectオプションの値の変更に応じて、テキストボックスの表示と表示するテキストボックスの数がajaxで変更されます。ただし、送信ボタンでそのテキストボックスを検証しようとしました。しかし、そのテキストボックスの値は、送信ボタンをクリックしている間は保持されません...jquery ajaxレスポンス・ポスト値のテキストボックスdiv

私の質問は、ajaxの応答divは、送信中にその値を保持することはできません?

Ajaxのレスポンスのdiv:

<?php 
foreach ($technical_skill as $skills){ 
?> 
    <div class="form-group col-md-12"> 
    <div class="col-md-4"> 
     <label for="bsl"><?php echo $skills['techskills'];?></label> 
    </div> 
    <div class="col-md-8"> 
     <input type="text" class="form-control technicalskill" name = "technicalskill[<?php echo $skills['id']; ?>]" id="bsl"> 
    </div> 
    </div><?php 
    } 
?> 

のjQueryのAjax:

$('#tskill').click(function(){ 
var parentid = $(this).val(); 
var text = $('option:selected', this).text(); 
    $.ajax({ 
     type:"POST", 
     url:"index.php", 
     data:{parentid:parentid}, 
     success:function(response){ 
     if(parentid == ''){ 
      $('#tech_head').css('display','none'); 
     }else{ 
      $('.tech_skill').html(response); 
      $('.tech_group').text('Technical Skill: '+text); 
      $('.hide-div').css('display','block'); 
     } 
     } 
    }); 
}); 
+0

はあなたが投稿することができて、あなたのjQueryを使用するよりも、あなたのコード

<div id = 'myDiv'> <input type = 'text' id = 'myText' > <input type = 'submit' id = 'submit' > </div> 

ですあなたのコード? –

答えて

0

シンプルなソリューション:

保存隠しフィールドに値、および送信関数はその値を検証しています。値は、選択されたイベントの直後に隠しフィールドに保存する必要があります。あなたが例えば

に、後でそれを使用することができますよりも、AJAXリクエストを送信する前に

0

コピー要素データは、ここでは

$('#submit').on('click', function(){ 
    temp = $('#myDiv'); 
    //your ajax code here 
    //now check with your elements value as temp.find('#myText').val(); 
}) 
関連する問題