简体   繁体   中英

html reset text area on frame form submit

I want to reset the text area on my submit which sends data without changing the page.

    <iframe name="votar" style="display:none;"></iframe>
    <form id ="myForm" action="message-process.php" method="post" target="votar">
      <?php
      echo "<input type='hidden' name='userId' value= '$sendId'>";
      ?>
        <textarea rows="5" cols="60" name="message" type="text" maxlength="255" style="font-size:10px background-color:grey;"></textarea>
        <input type="submit" value="Send Message">
    </form>

You can use HTML form attribute onsubmit="func()"

And inside a Javascript script set the value of what you wish to an empty string.

This code works.

    <iframe name="votar" style="display:none;"></iframe>
    <form id ="myForm" action="message-process.php" method="post" target="votar" onsubmit="this.submit(); this.reset(); return false;">
      <?php
      echo "<input type='hidden' name='userId' value= '$sendId'>";
      ?>
        <textarea id ='input' rows="5" cols="60" name="message" type="text" maxlength="255" style="font-size:10px background-color:grey;"></textarea>
        <input type="submit" value="Send Message">
    </form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM