Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
variable value to php base_url function

Below is my jQuery Code:

<script>
$(document).on('click','.quickview', function(){
var **image** = $(this).attr('image');
var testimage = document.getElementById('quickimage');
testimage.src= "<?= base_url().'assets/product_images/'.image.".png"?>";
});
</script>

I want to use this image value to the src attr of img which is in a modal, what is the best way can please help? I will be very thankful to you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't use JavaScript variables in PHP, since PHP runs on the server and finishes before the page is sent to the browser.

But you don't need to use the JS variable in PHP. You can do the concatenation in JavaScript.

testimage.src= <?= json_encode(base_url()) ?> + `assets/product_images/${image}.png`;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!