Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset Form Dropdown Problem

Status
Not open for further replies.

luckydexte

Programmer
Apr 26, 2001
84
US
Hello,

I have a form with a dropdown list and text box. I also have a reset button. I am trying to reset the dropdown list to the first value but I am not having any success. The text box is clearing so I know that I am getting to the Javascript function. My form and Javascript function are below. Any help would be appreciated.

Brandon Goodman

<form name="edu" method="post" action=" >
<select name="category" size="1">
<option value="">All&nbsp;
<option value="ASP" selected>ASP Classes&nbsp;
<option value="C#">C# Classes&nbsp;
<option value="HTML">HTML Classes&nbsp;
</select>

<input type="text" name="desc" size="30" maxlength="30" value="XXX"></td>
<input type="button" name="reset" value=" Reset " onclick="javascript:resetFields(document.edu);">

Javascript:

function resetFields(form) {
form.category.selectedindex = 0;
form.desc.value = "";
}
 
You want the select box to be reset to the first value, right??

Code:
<script>
function resetFields(form) {
    form.category[0].selected = true;
    form.desc.value = "";
}

The above code will reset the dropdown to the first option (in this case it's ALL)




____________________________________
Just Imagine.
 
Thanks, that worked. I was having a brain feeze today and could not remember.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top