1

I have these javascript variables:

  $('#modalDescription').html(item.description);
  $('#exrtas-area-inside').append('<div class="custom-control custom-checkbox mb-3">
  <input onclick="recalculatePrice('+id+');" class="custom-control-input" id="'+element.id+'" 
  name="extra"  value="'+element.price+'" type="checkbox"><label class="custom-control-label" 
 for="'+element.id+'">'+element.name+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+'+element.priceFormated+'
  </label></div>');
          

these variables "item.description" and "element.name" I want to pass in php function.

Php function which is in common php file:

      function trsText ($text){  here language translation code }

now I want to pass the js parameters in that function to translate them, as I am translating php variables easily, but here name and description are coming from js code so I want to pass them in that particular php function.

2
  • 1
    If you want to send data from the browser to the server then you'd either use an AJAX request, or include them in a form post, or add them to a link or navigation event. Commented Oct 19, 2021 at 10:51
  • Does this answer your question? Pass variable value from JS to PHP Commented Oct 20, 2021 at 0:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.