Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down Auto Drop on Focus

Status
Not open for further replies.

Raj1Patel

Programmer
Jan 29, 2002
5
0
0
GB
Hi,

I am looking to get a Drop Down box to drop down when it recevies foucs, through Javascript. Can anyone help?

Raj.
 
Hi Raj,

It's probably not exactly what you want, but try this (I tried something with the click() method, but that doesn't seem to work.):

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY onload=&quot;openSB('sb1')&quot;>
<script language=&quot;javascript&quot;>

function openSB(sName)
{
var j = document.body.all[sName].length

document.body.all[sName].size = j
document.body.all[sName][0].selected = true
document.body.all[sName].focus()

}
</script>

<select name=&quot;sb1&quot;>
<option>option 1
<option>option 2
<option>option 3
<option>option 4
<option>option 5
<option>option 6
<option>option 7
<option>option 8
<option>option 9
</select>
<br>

</BODY>
</HTML>

hope this helps,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Hi Boomerrang,

Yes I had the same problem with the click event. It does not seem to drop the DropDown selection bit.

I like your idea, however, I am not looking to make it into a listbox just keep a DropDown.

I wonder if there is anyway of getting rid of the scroll bar on the right of the listbox and hey presto just what I am looking for.

Raj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top