Jump to content


Photo

Clear Form Button


  • Please log in to reply
3 replies to this topic

#1 essjay_d12

essjay_d12
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 29 March 2006 - 05:30 PM

How do I go about creating a button that clears values in form fields?

Ta

d

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 29 March 2006 - 05:36 PM

use asreset button like so:
<input type="reset" value="Reset Form Fields">


#3 essjay_d12

essjay_d12
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 29 March 2006 - 05:56 PM

is it possible to exclude certain input boxes ?

for example one is a readonly input box and i do not want that cleared.

ta
d


#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 March 2006 - 05:06 PM

You might want to use javascript to clear the fields you want clearing instead. Like this:
<script type="text/javascript">

function clearForm()
{
    document.formName.name.value = "";
    document.formName.email.value = "";
}

</script>

<form name="formName" action="fileName.php" method="get">
Name: <input type="text" name="name"><br />
Email: <input type="text" name="email"><br />
Special Field: <input type="text" name="special" value="doesn't get cleared" /><br />
<input type="button" value="Reset" onClick="clearForm()">
</form>
To add more follow this template:
document.[name of form here].[name of input field].value = "";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users