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

302
Views
How can I use JS attribute for links in PHP?

trying to understand. I have a js code,

 $(document).on('click','.plan_btn',function() {
        $('.ui-dropdown').removeClass('active');
        var tarifplanid=$(this).attr('data-tarifplanid');
        $('.planid').text(tarifplanid);
            $('.add_plan').addClass('show');
        });

I have a php code, with button, where I pass attr.

<button type="button" class="ui-component ui-button plan_btn" data-tarifplanid="<?php echo($plan->plan_id)?>">Select</button>

So, by pressing Select button, I will have an planID, which is 2 or 3 stored in .JS

Then, as test, I have the following code:

 <?php
    $test = <<<EOD
    <span class="planid"></span>
    EOD;
echo $test;?>

Question is:

  1. echo returns ID, 2 or 3, depends on which item I pressed "Select"
  2. But, when I trying to add a link with $test, it will as <span class="planid"></span>

Why? I assume it should be https://localhost/2 but I have https://localhost/<span class="planid"></span>

Thank you! I'm not a developer, just browsing and a learning a bit

about 4 years ago · Juan Pablo Isaza
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!