/    Sign up×
Community /Pin to ProfileBookmark

maintaining, selecting index in select pulldown

I have a web form that has several pull down menus and text fields. I have a button at the end of the page “Clear” and onclick I enter my clearinput(). All my clearinput does is set
document.AdvSearchForm.textNamefield = “”; for each and every text field.
Now every text input field is set to null. However, when my screen is repainted not only are all my input fields blank, but all my select pull down menus have been returned to their original state of index=0. I wanted them to stay with their selected valued. As long as selectedIndex is not being reset or document.AdvSearchForm.searctype[x].selected is not changed (true/false), why are all my select indexes going back to 0? An example of one pull down menu is

<tr>
<td height=”28″ align=”right” valign=”middle” bgcolor=”#DDDDDD” class=”style25″ >
Search Type:
</td>
<td colspan=”2″ valign=”middle” bgcolor=”#DDDDDD”>
<select id=”MySelect” name=”searchtype” onchange=”TransactionHandler()”>
<option selected=”selected” value=”0″> </option>
<option value=”1″>By Filer Name</option>
<option value=”2″>By Filer Account ID</option>
<option value=”3″>By Contributor/Payee</option>
<option value=”4″>By Fields other than Name/ID</option>
</select>
</td>
</tr>

Should I remove the selected=”selected” for my first pull down option?
Thanks!

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@tirnaMay 21.2010 — I have an idea but unless you post all your markup and javascript I would be guessing to some extent.

Reading peoples' minds to get their unposted code, which may or may not be relevant, is not my strong point. I skipped school the day they taught mind reading ?
Copy linkTweet thisAlerts:
@FangMay 21.2010 — When resetting forms, the select control will be returned to it's original value. Either to the [I]selected="selected"[/I] option or if not present to the first option.

Either save any changes in a cookie and load these after a reset, or just reset the input fields:var aObj=document.getElementsByTagName('input');
var i=aObj.length;
while(i--) {
aObj[i].value = '';
}
Further help will require the markup and javascript, as [B]tirna[/B] mentioned.
×

Success!

Help @thelouvre 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.20,
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,
)...