javascript - Clear button on addentry page doesn't work -
this addentry blog page have made scratch , there underlying problems code particularly clear button supposed clear text entered when button clicked on doesn't work have saved html file problem.
also 1 other problem submit button works doesn't pass of text index file have written php , reason whenever click on submit button redirects me index page without posting entry have made.
<!doctype html> <html> <head> <script> function message() { alert("clear form?"); } </script> <style> body {background-color: beige;} h1 {color: black;} p {color: black;} textarea { width: 50%; height: 150px; padding: 12px 20px; box-sizing: border-box; border: 2px solid #ccc; border-radius: 4px; background-color: white; font-size: 16px; resize: none; } div { padding-left: 20px; } </style> </head> <meta charset="utf-8"> <link rel="stylesheet" href="../../main.css"> <title>add entry</title> </head> <body> <div><h1>add entry</h1></div> <div><p><b>enter title of entry topic defined , add entry blog want write after finishing writing topic press submit button submit entry posted in main page of blog if wish discard or clear entry press clear button remove topic have written about.</b></p></div> <form onreset="message()"> <p><label>title</label> <input type = "text" id = "mytext"/></p> <p><label>entry</label> <textarea> <input type="clear"> </form> <form> <p><label>title</label> <input type = "text" id = "mytext"/></p> <p><label>entry</label> <textarea> </textarea></p> </form> <form method="post" action="index.html"> <button type="submit" value="submit">submit</button> <input type="button" value="clear" onclick="javascript:erasetext();"> </form> </body> </html>
particularly part of clear button code:
<script> function message() { alert("clear form?"); } </script> <form onreset="message()"> <p><label>title</label> <input type = "text" id = "mytext"/></p> <p><label>entry</label> <textarea> <input type="clear"> </form>
and submit button code:
<form method="post" action="index.html"> <button type="submit" value="submit">submit</button> <input type="button" value="clear" onclick="javascript:erasetext();"> </form>
1) use input field type="reset"
clear form
2) input field should same form post next page
note : using more 1 form , expecting other form values on index page.
<form method="post" action="index.html"> <label>title</label> <input type = "text" name="mytext" id ="mytext"/> <br> <br> <label>entry</label> <textarea name="area"> </textarea> <br> <br> <button type="submit" value="submit">submit</button> <input type="reset" value="clear" > </form>
Comments
Post a Comment