Not sure what to do? |
Not sure what to do? |
Mike Wazowski |
Dec 16 2020, 05:44 AM
Post
#1
|
Group: Members Posts: 4 Joined: 8-December 20 Member No.: 27,677 |
Hello. I am trying to do a simple form where the action is to send you to a new webpage but also the button you press is a href to send the form data to an email but the action or the href are not working?
CODE <form action="/website.html" method="POST"> <br> <br> <div class="coffeeandsugar"> <select name="drinks" id="drinks"> <option id="choose" value="Choose">Choose</option> <option id="coffee" value="Coffee">Coffee</option> <option id="OrangeJuice" value="OrangeJuice">Orange Juice</option> <option id="coke" value="Coke">Coke</option> <option id="wine" value="Wine">Wine</option> </select> <div id="output"></div> <div id="coffeetype" class="coffeetype"> <label>Latte</label><input type="checkbox" name="coffeetype" id="latte" value="latte"> <label>Americano</label><input type="checkbox" name="coffeetype" id="americano" value="americano"> <label>Cappucino</label><input type="checkbox" name="coffeetype" id="cappucino" value="cappucino"> </div> <div class="Sugars" id="Sugars" onload="sugar()"> <label>0 Sugar</label><input type="radio" name="Sugar" id="nosugar" value="0sugar"> <label>1 Sugar</label><input type="radio" name="Sugar" id="onesugar" value="1sugar"> <label>2 Sugar</label><input type="radio" name="Sugar" id="twosugar" value="2sugar"> <label>3 Sugar</label><input type="radio" name="Sugar" id="threesugar" value="3sugar"> </div> </select> <div id="size" class="size"> <h4>Drink Size</h4> <select name="drink-size" id="drink-size"> <option id="small" value="Small">Small</option> <option id="medium" value="Medium">Medium</option> <option id="large" value="Large">Large</option> </select> </div> </div> </fieldset> <br> <fieldset class="details-style"> <legend>Details</legend> <label>1st Name <input type="name" name="FstName" id="1stname" required></label> <br> <label>2nd Name <input type="name" name="ScdName" id="2ndname" required></label> <br> <label>Date Of Birth <input type="date" name="DOB"id="DOB" required></label> <br> <label>Male</label> <input onclick="male()" type="radio" name="gender" value="Male" id="man"> <br> <label>Female</label> <input onclick="female()" type="radio" name="gender" value="Female" id="woman"> <br> <label>Other</label> <input onclick="other()" type="radio" name="gender" value="other" id="extra"> <br> <label>Email <input type="email" name="Email" id="Email" required></label> <br> <label>Phone Number <input type="tel" id="Number" name="PhoneNumber" required></label> <br> <button type="submit" href="MAILTO:example123@gmail.com?subject=Order from Guy">Submit</button> </form> |
Christian J |
Dec 16 2020, 08:29 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
When you submit a form the browser will load the URL in the form's ACTION attribute ("/website.html"). That URL should also contain the server-side script (e.g. PHP) that sends the email (your webhost's support pages may have more information or ready scripts). The actual submit button does not use any HREF attribute.
See also https://htmlhelp.com/faq/html/forms.html#form-howto and the FAQ entry below it. |
pandy |
Dec 16 2020, 11:44 AM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
And the server-side script that sends the email can also send the user to another page.
But if you are stuck with mailto it should be used as the value of the action attribute in the FORM tag. Then the only way you can send the user to another page is with JavaScript. There are probably better ways, but this is one. CODE <form method="post" enctype="text/plain" action="mailto:example123@gmail.com?subject=Order from Guy" onSubmit=window.setTimeout('window.location.href="website.html"',3000)> The number there at the end (3000) is the time in milliseconds before the redirection takes place. This isn't reliable. But as Christian pointed out, neither is mailto. If possible, use a server-side script for form handling if this is of any importance. If it's just for fun and play and your own testing, well, mailto may work. Just remember it won't work for everyone. To start with many people only uses webmail these days and mailto won't do much then. |
Lo-Fi Version | Time is now: 28th March 2024 - 05:23 PM |