How do I make it so that answers to requests in a form show in the URL once submitted?

31 Views Asked by At

I am using VS code and a live server on my 127.0.0.1:5500 to visualize the code for me. After filling out the form properly and pressing the submit button, I do not see the url change. I also do not see a message if I do not fill in all required inputs.

Begins like this after:

<body>
    <h1> <u> Request a Quote</u></h1>
    <form action="." method="GET" >
        <div class="form-row">
            <label> 
                First name:
                <input type=text name="first-name" required >     
            <label>

And end like this:

 <div class="form-row">
     <button type="button" id="Submit"> Send </button>
     <button type="button" id="clear">Clear</button>
 </div>
    
</body>
</html>

I tried to figure out if it was the form action and method. I do not quite know how I should write that.

1

There are 1 best solutions below

6
Odysseus  Hash On

Do you expect that when you click send and Mike is in the input, the URL will be like this: http://127.0.0.1:5500/?first-name=Mike

<html>
    <body>
        <h1> <u> Request a Quote</u></h1>
        <form action="http://127.0.0.1:5500/" method="GET" >
                <label> 
                    First name:
                </label>
                    <input type="text" name="first-name" id="first-name">

                    <input type="submit" value="Send">
                    <input type="button" value="Clear" onclick="document.getElementById('first-name').value=''">

        </from>
    </body>
</html>

Perhaps this is what you're looking for