Click to See Complete Forum and Search --> : reset dropdown menus?


sanjuT
09-04-2003, 10:24 AM
Hi all!

I want to have a reset button reset 4 dropdowns that i have..i have this script, but not sure if i could modify it to work:
(these are not PHP code, it's just labelled that way for the formatting)


<!--
function reset()
{
document.filtermenus[0].elements[0].select();
}
//-->


the dropdowns are pop. from a database, hre's an example of one dropdown:


<select name="developer" onchange = "PostForm();">
<%
response.Write ("<option value ='''>No Filter </option>")
if rsDeveloper.eof = false then
rsDeveloper.movefirst
while not rsDeveloper.eof
if len(developer)>0 then
if rsDeveloper("UserName") = (developer) then
selected = "Selected"
else
selected = ""
end if
end if
response.Write ("<option " & selected & " value ='" & rsDeveloper("UserName") & "'>" & rsDeveloper("UserName") & "</option>")

rsDeveloper.MoveNext
wend
end if
%>
</select>


Is it possible to reset these types of dropdowns?

THANKS!!!

Jona
09-04-2003, 02:57 PM
Dropdown menus (select menus) dynamically created by the server can be edited after the page has loaded as "regular" ones can. The JavaScript code you've posted wouldn't work. Could you explain what you're trying to do better, please?

[J]ona

pcolafl
09-04-2003, 03:45 PM
window.location.reload();

sanjuT
09-04-2003, 03:57 PM
i tried:

onClick = "window.location.reload()";

for the reset button tag, netscape 4.76 just kinda freezes, looks like an unterminated loop or something.

i have a page with a list of projects that can be displayed according to which filters the user selects, from the dropdowns.
the default page when it loads is the entire list of projects (no filters).

These filters can be used together. For example, I can filter for a developer named bill, and within those i can filter by contact name (another filter, or dropdown). there ar 4 dropdowns on the page.

It is too much to ask the user to select 'No Filter' from each dropdown they used, if they want to have the entire list visible again.

So I want an easy way for them to do it, a button that resets all filters to the 'No Filter' option.

THANKS!

Jona
09-04-2003, 07:32 PM
Use a for() loop. Something like this...


for(i=0; i<4; i++){
document.forms[i].selectboxName.options[0].selected=true;
}


[J]ona

sanjuT
09-05-2003, 08:31 AM
for the selectboxname, i have 4 different names, how would I use your code?

THANKS!!

Jona
09-05-2003, 12:09 PM
My code would work if all of the select boxes were named the same but in different forms. If they are in the same form, you may have to use eval().

[J]ona

sanjuT
09-09-2003, 11:54 AM
thanks, but i'm still lost.

how exactly do i use the eval()?

would i use 4 different lines for each dropdown?

Jona
09-09-2003, 02:21 PM
document.forms["formName1"].selectBoxName1.options[0].selected=true;
document.forms["formName2"].selectBoxName2.options[0].selected=true;
document.forms["formName3"].selectBoxName3.options[0].selected=true;
document.forms["formName4"].selectBoxName4.options[0].selected=true;


[J]ona

sanjuT
09-09-2003, 03:25 PM
thanks a lot! u have been extremely helpful, i appreciate it!

one last quickie, when the dropdowns get reset, what can i add to the function that will reload the page?

thanks!

Jona
09-09-2003, 03:45 PM
window.location.reload();
// or
location.reload();


[J]ona

sanjuT
09-09-2003, 04:01 PM
as usual, u have helped me greatly.

thank you again!:D

Jona
09-09-2003, 05:45 PM
No problem. :)

[J]ona