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

379
Visualizações
How to inject working alert code from a HTML text form?

I am fairly new coding in JavaScript and web development, and I was wondering if there was any way to input an alert through an HTML text form and have it run on another page after it has been submitted, right now this is what I have.

index.html

<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>form</title>
</head>
<body>
    <form action="results.html" method="GET">
        <div>
            <label>Name</label> <input style="width: 400px;" size=400px type="text" name="name" id="name" placeholder="username" required>
        </div>
        
        <button type="reset">Reset</button>

        <button type="submit">Submit</button>
    </form>
</body>

results.html

<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Results</title>
</head>
<body>
    
    <div id="results"></div>
    
    <a href="index.html">Back to Form</a>

    <script>
        const resultsList = document.getElementById('results')
        new URLSearchParams(window.location.search).forEach((value,
        name) => {
             resultsList.append(`${name}: ${value}`)
             resultsList.append(document.createElement('br'))
         })
    </script>
</body>

I want to get something like this

My input

What I am trying to achieve

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

0

You have to receive a variable that you send with the "get" method.

With the window.location object. This code gives you GET without the question mark.

 let myTextAlert =   window.location.search.substr(1)

(You can use split() method to get rid of &)

Next in Your div or insert js:

<div id="results">

<script>
  alert("This page Says:" + myTextAlert); 
</script> 

</div>
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