How can I get text inside the combobox to add to the database?
For example, "AC" or "AL."
<select>
<option value="1">AC</option>
<option value="2">AL</option>
...
</select>
How can I get text inside the combobox to add to the database?
For example, "AC" or "AL."
<select>
<option value="1">AC</option>
<option value="2">AL</option>
...
</select>
Use jQuery and send your data to the bank with Ajax:
$('select[name="combobox"]').change(function(){
var text = $('select[name="combobox"] option:selected').text();
$.ajax({
url: "savar-no-bd.php",
type: "POST",
data: {texto: text},
success: function(data){
console.log(data);
}
});
});
You can use jQuery.
jQuery
$(function(){
$("select").change(function(){
var that=$(this).children('option:selected');
alert(that.text());
});
});
HTML
<select name="combobox">
<option value="1" class="option">Combobox Text</option>
<option value="2" class="option">Combobox Text 2</option>
</select>