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

217
Visualizações
How to Add javascript variable inside html attribute

I have a form and I want to add javascript variable inside the value="". value="embedurl" I am new to adding javascript variable inside html, so far, all of the solutions that i found on google is not working. How to do this? Thanks.

<form id="landing2" action="https://example.com/post10/" method="post">
<input type="hidden" name="name" value=" var embedurl ">
<input type="submit">
</form>

<script>
var embedurl ="https://" + document.location.host + "/embed" + window.location.pathname;
    document.getElementById('landing2').submit();
</script>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try this ,

var embedurl ="https://" + document.location.host + "/embed" + window.location.pathname;
document.getElementsByName("name")[0].value = embedurl; // here you need to set the input value
document.getElementById('landing2').submit();
about 4 years ago · Juan Pablo Isaza Relatório

0

If you want to add a javascript value, you must do it by javascript.

First, you need to get the dom input element, then set the value

var form = document.getElementById("landing2");
var input = form["name"];

input.value = embedurl;
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