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

221
Visualizações
Passing a value to Javascript - via a link

The below excluding the creation of the $order_id_inpro is all inside an PHP echo.

$order_id_inpro = "1234";
<a class="dropdown-item" onclick="myFunction2('.$order_id_inpro.')">Upgrade Order</a>

At the bottom before my </body> I have the below script.

<script>
function myFunction2() {
  var msg2=encodeURIComponent(this.id);
  var myWindow = window.open("https://myurl.com/OaJER1?orderNumber="+ msg2 , "MsgWindow", "width=650,height=1000");
}
</script>

The results is that I get "orderNumber=undefined" at the end of the URL.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The onclick is passing the order number as a function argument, you need to get it using a function parameter.

function myFunction2(msg2) {
  var myWindow = window.open("https://myurl.com/OaJER1?orderNumber=" + msg2, "MsgWindow", "width=650,height=1000");
}

Inside the function, this is the global window object, so this.id is window.id, which is undefined.

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