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

378
Vistas
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 Respuestas
Responde la pregunta

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