Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda