AW: [Javascript] Re: <select> focussieren
Michael Borchers
borchers at tridem.de
Tue Feb 8 06:54:33 CST 2005
hm, thanks, but it doesn't seem to work when loading the page.
here is more of the code:
<form action="/software/reparaturen.php" method="post" name="reparatur" target="magh" onSubmit="self.close()">
<script language="JavaScript" type="text/javascript">
document.reparatur.getElementById("art").focus();
</script>
<select name="art" onChange="fahrzeugkauf()">
<option value=""></option>
<option value="A">A</option>
<option value="D">D</option>
<option value="I">I</option>
<option value="L">L</option>
<option value="T" selected>T</option>
<option value="Text">Text</option>
<option value="F">F</option>
</select>
</form>
should the javascript start before the form or what else can be wrong?
> -----Ursprüngliche Nachricht-----
> Von: Matt Barton [mailto:javascript at mattbarton.org]
> Gesendet: Dienstag, 8. Februar 2005 13:38
> An: [JavaScript List]
> Betreff: Re: [Javascript] Re: <select> focussieren
>
>
> This is one way to do it:
>
> To ensure that the correct option is selected when the page
> loads then
> the html should resemble this:
>
> <select id="theSelect">
> <option value="a">This should not be selected</option>
> <option value="b" selected>This SHOULD be selected</option>
> </select>
>
> It is the "selected" part of the correct <option> tag that makes it
> appear selected.
>
> To get the focus onto the select control, you've almost got it right.
> The javascript for the above example could be:
>
> document.getElementById("theSelect").focus();
>
> There's many similar ways to achieve the same thing though:
> this is just
> one.
>
> HTH
>
> Matt
>
>
> Michael Borchers wrote:
> > oh, sorry for that!
> >
> > i would like to focus a <select><option ... > field when
> > loading a form, so I can browse the options with the mouse
> wheel f.e.,
> > but without using a onLoad() in the <body> tag, is that possible?
> >
> > document.formname.selectname.options.focus();
> >
> > did not work
> > neither
> >
> >
> document.formname.selectname.options[document.formname.selectn
> ame.selectedIndex].value.focus();
> >
> >
> >
> >
> >>> -----Ursprüngliche Nachricht-----
> >>>Von: Michael Borchers
> >>>Gesendet: Dienstag, 8. Februar 2005 13:23
> >>>An: Javascript (E-Mail)
> >>>Betreff: <select> focussieren
> >>>
> >>>undzwar direkt beim aufruf des formulares ohne <body> tag,
> >>
> >>geht das?
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
More information about the Javascript
mailing list