/    Sign up×
Community /Pin to ProfileBookmark

dropdowns don’t reset in IE

I have 4 dropdowns on a page, they act like filters, the info on the page changes to what was selected in the dropdown.
Example of 2 of the dropdowns:

[code=php]

<form name=”filtermenus” method=”POST” action=”Projectlist.asp”>
&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp&nbsp;&nbsp;<b> <i>&nbsp;&nbsp;Developer</i>:</b>
<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>

&nbsp;&nbsp;&nbsp<b> <i>Priority</i>:</b>
<select name=”priority” onchange = “PostForm();”>
<%
response.Write (“<option value =”’>No Filter </option>”)
rsPriority.movefirst
while not rsPriority.eof
if len(priority)>0 then
if rsPriority(“priorityid”) = cint(priority) then
selected = “Selected”
else
selected = “”
end if
end if
response.Write (“<option ” & selected & ” value ='” & rsPriority(“PriorityID”) & “‘>” & rsPriority(“Description”) & “</option>”)

rsPriority.MoveNext
wend
%>
</select>
[/code]

I use this to reset the filters in Nestscape 4.76:

[code=php]
function resetfilter() {

document.filtermenus.developer.options[0].selectedIndex = 0;
document.filtermenus.priority.options[0].selectedIndex = 0;
document.filtermenus.status.options[0].selectedIndex = 0;
document.filtermenus.contact.options[0].selectedIndex = 0;

//PostForm();
window.location.reload();

}return true;

[/code]

why doesn’t this work in IE?
the page just reloads, after clicking ‘retry’, and the filters are unchanged.

THANKS!!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisOct 06.2003 — An OPTION does not have a selectedIndex property. That is a property of the SELECT tag. The only reason it works in Netscape is because of the "window.location.reload()". The syntax you should use is:<i>
</i>document.filtermenus.developer.selectedIndex = 0;

You should see the drop-down change as soon as you execute the statement. You should not need to reload the page just for that.
×

Success!

Help @sanjuT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...