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

191
Vistas
Jquery inside a php file to replace a form value with a URL Parameter

so I have a a PHP Form handler that I have a hidden field in. I use this all the time in my header, however, I have not used it inside a php file. I access the jquery library, use $(document).ready(function () and have my variables inside, as well as getURLParameter("tid"), then ($tbody).html $("tbody").html($("tbody").html().replace(/{{transaction_id}}/g,replaceString));

I keep getting the error: Uncaught ReferenceError: getURLParameter is not defined

I'm probably missing something here, as I have not done this inside a PHP file before.

Should I use .php instead of .html?

Here is the snippet of code:

<?php } ?>
    <table width="250"><tbody>
        <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script>
$(document).ready(function () {
    var replaceString = "NO TID";
    var urlTerm = getURLParameter("tid");
    if (urlTerm.trim().length > 0 && urlTerm != "null") {
        replaceString = decodeURIComponent(urlTerm).replace(/\+/g,' ');
    }
    $("input.transaction_id").html($("input.transaction_id").html().replace(/\{\{transaction_id\}\}/g,replaceString));
});
</script>
<tr><td><form id="signupform" class="signup_form" action="/testing-kirby.php" method="post"><div><div><input  class="signup-name-area" style="height: 32px; width: 325px;" name="name" type="text" placeholder="Full Name"><br><br><input class="signup-email-area" style="height: 32px; width: 325px;" name="email" required="required" type="email" placeholder="email@example.com"><div style=" margin-top: 15px;"<center><input class="signup-button-2" style="background-color: red; height: 48px;" type="submit" value="Sign Petition"></center></div><input name="loc" type="hidden" value="header"></div></div><input name="tid" class="transaction_id" type="hidden" value="{{transaction_id}}"></div></form><p style="text-align: center;">Sponsored by:</p><p style="text-align:center;"><img src="https://wolfdaily.com/wp-content/uploads/2020/05/Wolf-Daily-Final-160h.png" width="200"></p></td></tr></tbody></table>

Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You don't need to replace it with jQuery. If its php you can get the url parameter like

var urlTerm = "<?php echo $_GET["tid"] ?>";

However if you still wana do it with JavaScript consider the solution here because you need to define the function getURLParameter somewhere in your code or you forgot to import it.

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