0
votes

Depends upon the select option value change click displaying textbox name and number of displaying text box will changed with my ajax.But i tried to validate that text box in submit button. But that textbox values are not keep while submit button click...

MY question is ajax response div is not able to keep that values while submit???

Ajax response 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');
        }
      }
    });
});
2
can you post your codes? - Sam Teng Wong

2 Answers

0
votes

Simple solution:

Save values to a hidden field, and have the submit function validate that value. Values should be saved to hidden field immediately upon select event.

0
votes

Copy element data before sending a ajax request than you can use it later to

For example here is your code

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

than use your jquery as

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