Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda