How I get the text instead value from a select option in CodeIgniter

kapantzak

I have a form in which there is a select field with many options. These options have numeric values and a text between option tags. What I want to do is to get the text instead of values when I post the form via submit button.

View that generates the select field:

echo form_dropdown('pos', $pos_options, '100', 'id="pos_select" class="form_input"'); 

the select part generated:

<select name="pos" id="pos_select" class="form_input">
    <option value="0">about_history_title</option>
    <option vlaue="1">about_history</option>
</select>

When the form is submited, the appropriate model is called via the controller(text.php):

text.php -> insert_text()

$this->admin_text_model->insert_text();

admin_text_model.php

public function insert_text()
{
    $data = array(
        'tx_page' => $this->input->post('page'),
        'tx_pos' => $this->input->post('pos'),
        'tx_body' => $this->input->post('add_text')
    );

    return $this->db->insert('text', $data);
}

Is there a way that I can get the text inside option tags in $this->input->post('pos')?

Perhaps something like:

'tx_pos' => $this->input->post('pos')->text?
Jitendra Yadav

Try this don't assign the value to option tag:

<select name="pos" id="pos_select" class="form_input">
    <option>about_history_title</option>
    <option>about_history</option>
</select>

It will return text of option.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I get the text and not the value of an Option?

From Dev

bootstrap select option display value instead of text

From Dev

How to get the text box instead of dropdown select box if get null value from json

From Dev

How to get the text box instead of dropdown select box if get null value from json

From Dev

How can i get text option from AJAX generated select dropdown using jQuery?

From Dev

How to send option value (instead of the html text inside) of select option dropdown via ajax post?

From Dev

How to get the value of a select's option by its text

From Dev

How can I hide an option of a select by it's text value?

From Dev

How do I get value of select option for current row

From Dev

How can I get value when click option in the select on vue?

From Dev

How I can get a value from a text file and select a checkbox who have that value?

From Dev

How can I get selectize to insert the text of the option, not just the value?

From Dev

Angular 2 - how to get value from select / option

From Dev

How to get specific value from option select - json object

From Dev

How to get the selected option value from select inside div

From Dev

How to get value of Select option from loop in JavaScript

From Dev

how to add text area when i select any option from select option

From Dev

Retrieve text (not value) from select option tag

From Dev

how can i get two values from one select option?

From Dev

How do I grab the option text from a value

From Dev

Get value from select statement in codeigniter?

From Dev

Get selected option value from specific select

From Dev

Get Attribute Value From Specific Select Option

From Dev

How fo i retrieve option label instead of option value

From Dev

How to get option value of select element

From Dev

How to get the option value of selected in Select dropdown

From Dev

How to get selected value/text from HTML Select in codebehind

From Dev

How to get Select option dropdown text value using reactive form in Angular

From Dev

In Javascript how do I add a new option into Html Select so inserted based on alphabetical value of text

Related Related

  1. 1

    How do I get the text and not the value of an Option?

  2. 2

    bootstrap select option display value instead of text

  3. 3

    How to get the text box instead of dropdown select box if get null value from json

  4. 4

    How to get the text box instead of dropdown select box if get null value from json

  5. 5

    How can i get text option from AJAX generated select dropdown using jQuery?

  6. 6

    How to send option value (instead of the html text inside) of select option dropdown via ajax post?

  7. 7

    How to get the value of a select's option by its text

  8. 8

    How can I hide an option of a select by it's text value?

  9. 9

    How do I get value of select option for current row

  10. 10

    How can I get value when click option in the select on vue?

  11. 11

    How I can get a value from a text file and select a checkbox who have that value?

  12. 12

    How can I get selectize to insert the text of the option, not just the value?

  13. 13

    Angular 2 - how to get value from select / option

  14. 14

    How to get specific value from option select - json object

  15. 15

    How to get the selected option value from select inside div

  16. 16

    How to get value of Select option from loop in JavaScript

  17. 17

    how to add text area when i select any option from select option

  18. 18

    Retrieve text (not value) from select option tag

  19. 19

    how can i get two values from one select option?

  20. 20

    How do I grab the option text from a value

  21. 21

    Get value from select statement in codeigniter?

  22. 22

    Get selected option value from specific select

  23. 23

    Get Attribute Value From Specific Select Option

  24. 24

    How fo i retrieve option label instead of option value

  25. 25

    How to get option value of select element

  26. 26

    How to get the option value of selected in Select dropdown

  27. 27

    How to get selected value/text from HTML Select in codebehind

  28. 28

    How to get Select option dropdown text value using reactive form in Angular

  29. 29

    In Javascript how do I add a new option into Html Select so inserted based on alphabetical value of text

HotTag

Archive