1

text box value disappear when i clicked the submit button in CI i want to make it not disappear

 $textbox_data = array(
     'name'      => 'playlist_text',
     'id'        => 'playlist',
     'maxlength' => '200',
     'size'      => '100',
     'style'     => 'width:1070px',
     'class'     =>  'form-control',
     'value'     => $textbox_value,
);

echo form_input($textbox_data);

$textbox_value = $this->input->post('playlist_text',TRUE);

could anyone help me? thanks :)

Karim Omaya
  • 841
  • 7
  • 7
  • can you elaborate more? when submitting the form refresh but you want to keep the text for each text inputs? – tonoslfx Feb 04 '15 at 11:44
  • use ajax post after successfull submit redirect through javascript http://stackoverflow.com/questions/18821492/code-igniter-how-to-return-json-response-from-controller/18821655#18821655 – Sundar Feb 04 '15 at 11:47
  • Where you are trying to get $textbox_value post data ?? I think you will get your post data in your controller file. –  Feb 04 '15 at 12:08
  • 'value' => set_value('playlist_text', $textbox_value) – AdrienXL Feb 04 '15 at 12:10

2 Answers2

1

You can use set_value() function:

<input type="text" value="<?php echo set_value('category_title');?>" placeholder="Category Title" id="category_title" class="form-control" name="category_title">
0

This is what you need: CodeIgniter's Form Helper

set_value()

Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function. The second (optional) parameter allows you to set a default value for the form. Example:

<input type="text" name="quantity" value="<?php echo set_value('quantity', '0');?>" size="50" />

The above form will show "0" when loaded for the first time.