Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!