1

I am trying to get value from dynamic created input field But its not fetching. its fetching only static field row.

Bellow is my code

<input type="text" id="job_title_id" name ="job_title_id[]" value="<?php echo set_value('job_title_id'); ?>">

script for creating dynamic input box

$(document).ready(function() {

  var max_fields      = 3;                      //maximum input boxes allowed
  var wrapper         = $(".input_fields_wrap");    //Fields wrapper
  var add_button      = $(".add_field_button");     //Add button ID
  var x = 1;                                         //initlal text box count
  $(add_button).click(function(e){              //on add input button click
    e.preventDefault();
    if(x < max_fields){                         //max input box allowed
        x++;                                    //text box increment
        $(wrapper).append('<div class="detailroweno"><span class="code"><input type="text" name="job_title_id[]"/></span></div>'); //add input box
    }
  });
})

Once i submit the code i am trying to get value on controller in codeigniter by dynamic created field data is not displaying

I tried to display using bellow php code in controller once i click to submit form

print_r($_REQUEST);

$results=$this->input->post('job_title_id');

print_r($results);

even i follow this link http://www.infotuts.com/dynamically-add-input-fields-submit-to-database/ Please help me out of this.. Thanks in advance.

8
  • .input_fields_wrap wrapper is inside or outside of your form?? Commented Jan 13, 2015 at 5:55
  • .input_fields_wrap is inside the form Commented Jan 13, 2015 at 9:41
  • Why you have placed [] in name? Commented Jan 13, 2015 at 9:47
  • To make job_title_id as array. because there will create multiple input field with job_title_id Commented Jan 14, 2015 at 5:14
  • Did you find the answer i'm looking for the same issue? Commented Jan 14, 2015 at 9:09

1 Answer 1

0

I was able to fix the issue by putting input tag into form. Your input tag isn't in form tag.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.