[Javascript] Reset the value of a SET of fields

David Yee david at amsresponse.com
Wed May 19 19:00:58 CDT 2004


Hi all.  How can I write a function that will reset the value of a SET of
fields (in this case, first_name_2, last_name_2, and email_2 would
constitute one set) to blank? Basically this function will linked by a
button next to each set of fields.  

<form name=my_form method=POST>
<input type=first_name_1 size=10>
<input type=last_name_1 size=20>
<input type=email_1 size=30>

<input type=first_name_2 size=10>
<input type=last_name_2 size=20>
<input type=email_2 size=30>

<input type=first_name_2 size=10>
<input type=last_name_2 size=20>
<input type=email_2 size=30>
</form>


I tried something like:

<script language=javascript>
function clear_row(form_name, num)
{
	document.form_name.first_name + num = '';
	document.form_name.last_name + num = '';
	document.form_name.email + num = '';
}
</script>


One button would be like:

<input type=button onclick="clear_row(myform, 2)">

But obviously the syntax is wrong in the function.  Thanks for any help.

David



More information about the Javascript mailing list