javascript - Need option text from select field stored in Woocommerce order -
i'm using custom post types in woocommerce checkout page - add details of car entering race. car fields pulled cpt car's based on user_id logged in user. problem facing value getting stored in order rather text of field. eg. ford, fiesta, 2001, black, getting in order 488, 488, 488 etc
i storing class user entering car in - showing correct on front end - storing value in end. i've tried jquery/javascript - couldn't work. code:
<script type="text/javascript"> var car_text = $("#my_car_select option:selected").text(); $(function(){ $('select').change(function(){ $('select').val( $(this).val() ); var selectedtext = $("#my_car_select")[0].textcontent }) }) $car_selected_name = $('#my_car_select:selected').text(); $("#my_car_select").change(function(){ var car_text = $("#my_car_select option:selected").text(); }); </script>
i've tried query cpt based on id - doesn't work either, keep getting array, not field text.
i frustrated option text on screen on front end not getting stored on backend - simple can't figure out. appreciated. thanks.
from have said sounds need value selected option?
you have right need space before :selected e.g
var selected_text = $('#my_car_select :selected').text();
which should return selected element.
let me know if still causing issues, might see source of element need fetch from.
Comments
Post a Comment