Insert name, not value of a select to my BD

0

I have an update form, where is a select and you can choose the area if you want to edit, when choosing any, in my database update the value of the option.

These data are filled through js, they are not static inside the html.

In an html table where the data is displayed, when updating the area, it shows me the value 2, which corresponds to Auxitrol. And where I need to show the word.

I am filling the data in the table by means of a function in js. And this is where I say it will show the area.

var CellArea = document.createElement('td');
CellArea.innerHTML = activos[i].name_area;
    
asked by Pato 26.11.2018 в 17:34
source

3 answers

1

You have to use .text (), no .value

    
answered by 26.11.2018 в 17:37
0

You must place the value of the options as a name, not as a number:

<select>
  <option value="norwich">norwich</option>
  <option value="todas las areas">todas las areas</option>
  <option value="auxitrol">auxitrol</option>
  <option value="westorm">westorm</option>
</select>

and the database change the field from int to varchar () ; And this should solve your problem!

    
answered by 26.11.2018 в 17:38
0

In the function you are using the value, not the text:

 function register() { 
    //Crea Formdata para ser enviado 
    var fd = new FormData(); 
    fd.append('name_area', document.getElementById('outArea').text());
 }

Putting text would take as value the text that you got in the option

    
answered by 26.11.2018 в 17:40