[Javascript] Positioning within a select box

Ben ben at babelfish.co.uk
Tue Mar 20 17:32:12 CST 2001


Sorry, I'm lost to what you're attempting!  err... you *do* want it at the
top? or not?

sorry if I'm being really thick.

 .b

> -----Original Message-----
> From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
> Behalf Of Mark Christie
> Sent: 20 March 2001 22:44
> To: 'javascript at LaTech.edu'
> Subject: RE: [Javascript] Positioning within a select box
>
>
> Thanx, Ben...Gotta preserve the order too...The app has an international
> audience...
>
> So far, here is my kludge:
>
> function checkBack() {
> 	var objLangSelect = document.forms.frmLanguage.iLangSelect;
> 	var iLangCount = 0;
>
> 	for(i=0; i < objLangSelect.length; ++i)
> 		if(objLangSelect[i].selected)
> 			++iLangCount;
>
> 	if(!iLangCount) {
> 		objLangSelect.selectedIndex = 13;
> //positions toward the end of list
> 		objLangSelect.selectedIndex = 8;
> //scrolls back and positions on English
> 		objLangSelect.selectedIndex = -1;
> //unselects English
> 	}
> }
>
> It's ugly, but it works lovely when first coming to the page and
> nothing is
> selected.  But if I return to the page with previous selections, using
> selectedIndex wipes them out.
>
> Any ideas?
>
> Regards,
>    -Mark C.
>
>
> -----Original Message-----
> From: Ben [mailto:ben at babelfish.co.uk]
> Sent: Tuesday, March 20, 2001 4:06 PM
> To: javascript at LaTech.edu
> Subject: RE: [Javascript] Positioning within a select box
>
>
> > Greetings, list...
> >
> > I have a list of about 30 or so languages to choose from in a
> select box,
> > from Arabic to Thai.  Since the list is alphabetized, when the
> > page pops up,
> > Arabic is the top selection.  What I want to do is position the
> > display such
> > that English, the 9th language in the list, is the top selection.
> >  How can I
> > do this?
> >
> > Regards,
> >    -Mark C.
>
> Mark.  Did you want English at the top of the list or just to be
> automaticly
> selected when the page loads?  If you want it at the top of the list then
> put the English <option> entry directly after the opening
> <select> tag.  If
> you want English to be automaticly selected then add the "selected"
> attribute to the English <option> tag, like this:
>
> 	<option selected>English</option>
>
> I recommend pre-selecting ov er re-ordering, but this can sometimes offend
> non-English-based visitors to the site.
>
> Hope this helps.
>
>  .b
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list