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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox always on top

Status
Not open for further replies.

cellops

IS-IT--Management
Apr 20, 2001
4
0
0
GB
Hi,

I have an input field followed by a listbox. When the input field is entered a javascript calander pops up. Unfortunately the listbox always displays infront of the calendar. Any ideas?
 
Why not use layers?? Or div tags?? I have not failed; I merely found 100,000 different ways of not succeding...
 
Hi,

Thanks for the response. Please bear with me as I am fairly new to this. The calendar is linked to a to a <DIV> tag already but it still displays behind the listbox.
I have included the code below and any help would be gratefully received.

The calendar I'm afraid I shamelessly stole from


and the html is :-

<html>
<head>
<title>Untitled</title>
<script src=&quot;DatePicker.js&quot;></script>
</head>

<body>
<table>
<tr>
<td>
<input type=&quot;text&quot; id=&quot;bob&quot;>
</tr>
</td>
<tr>
<td>
<input type=&quot;text&quot; id=&quot;benluc&quot;>
</tr>
</td>
<tr>
<td>
test listbox trial<select name=&quot;test&quot;>
<option>10000000000000</option>
<option>10000000000000</option>
</select>
</tr>
</td>
</table>
<script>
x = new DatePicker(document.getElementById(&quot;bob&quot;), &quot;x&quot;);
y = new DatePicker(document.getElementById(&quot;benluc&quot;), &quot;y&quot;);
</script>
</body>
</html>
 
I have a couple of questions:
1) Why are you using this: <input type=&quot;text&quot; id=&quot;bob&quot;>, I just did a testpage of it and when I click in the textbox the calendar appears, what is the reason for the textbox...do you just want the user to click for the calendar to appear??
2) You're problem isn't in the HTML code, I belive it's in the .js file...if you open the .js file and look at this code:

this.html.style.top = window.event.clientY+&quot;px&quot;;
this.html.style.left = window.event.clientX+&quot;px&quot;;
This means that whereever the user clicks the box (in your case the input box) the calendart will appear...
3) What is the purpose of the drop-down menu?? I'm only asking because it sometimes help knowing the layout of the page when debugging...
Let me see if I can re-configure the script, but in any case post this question in the Javascript forum here and maybe someone can solve the problem alot quicker...ok??

PS -- There's no shame in borrowing a script, as long as you give proper credit where due...I borrow scripts as well, in fact all programmer's borrow even the best-of-the-best... I have not failed; I merely found 100,000 different ways of not succeding...
 
I had the same problem. This is a feature of the browser. See thread215-138900. What I had to do to fix this was:
Code:
selects = document.getElementsByTagName( 'select' );
Then hide all the selects when you pop up the div with code similar to:
Code:
function showDiv() {
    for( var s = 0; s < selects.length; s++ )
        selects[s].style.visibility = &quot;hidden&quot;;
    }
    div.style.visibility = &quot;visible&quot;;
}
function hideDiv() {
    for( var s = 0; s < selects.length; s++ )
        selects[s].style.visibility = &quot;visible&quot;;
    }
    div.style.visibility = &quot;hidden&quot;;
}
I actually use an algorithm to determine if a select would overlap with the div, which I term a 'minimal hide'. This is done by recursing up through the offsetParent hierarchy for a select, and adding up the offsetLeft and offsetTop values to determine the vertices of the select box. I leave this as an excercise for you ;-)

Cheers, Neil
 
PS -- sorry I thought you posted the question in the HTML forum... I have not failed; I merely found 100,000 different ways of not succeding...
 
Hi,

Thanks for the responses.
I tried hiding the listbox when the calendar appears and re-displaying it when the user has selected a date and the calendar is destroyed. This works beautifully.
Thanks again to both of you for your help

Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top