Forum Moderators: open

Message Too Old, No Replies

div overflow inside form

         

Christina

8:44 pm on Sep 3, 2002 (gmt 0)



A script at my site returns many sets of hundreds of lines of data each. My boss saw a site which does the same thing, but puts their sets of results inside div tags with the overflow set to auto, so the user doesn't get a page that is many many screenfulls long. Of course, now we have to have the same thing. The problem is, our data sets are inside a form, because the user can then choose parts of the data via checkboxes and submit to another script. Mozilla and Netscape 6.2 are completely refusing to show the div/overflow when it is inside a form. It's like the stuff in the div isn't even there. It works fine in IE 5.5. I've tried it with Mozilla and N6.2 on many platforms - Mac OSX fails, Linux fails, Win98 fails, but on WinNT it works fine. Ugh. (Yes, the site we got the idea from has the same problem.)

Here is a little page that demonstrates the problem:
----------------------------------------------------------


<html>
<head> <title>test form and div</title> </head>
<body>
Before the form and div elements.
<form action="temp1.html">
After the form tag, before the div tag.
<!--
Three different divs to try:
<div style="width: 50%;">
<div style="width: 50%; height: 50%; overflow: auto;">
<div style="width: 50%; height: 50%;">
-->
<div style="width: 50%; height: 50%; overflow: auto;">
Hi there, this is a long line (how about we make it longer) inside the form and div elements
</div>
After closing the div tag, before closing the form tag.
</form>
After closing the form element.
</body></html>

---------------------------------------------------------------------

I've included three different divs. Each of the height and overflow
attributes seem to cause the problem.

I've looked through the HTML4.01 and CSS1/2 specs and haven't found anything saying I can't do this. I've run the code through the W3C HTML and CSS validators, which found no errors.

Anyone know what is going on here?

Thanks!
Christina

Nick_W

8:54 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, welcome to WebmasterWorld!

Are you trying to add or miss out a scroll bar here?

I read your post twice and can't work out what you're trying to do ;)

Nick

bobriggs

9:03 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure either; is overflow:scroll; what you're looking for?

The meaning of auto is up to the browser.

Christina

9:07 pm on Sep 3, 2002 (gmt 0)



Hi Nick,

Sorry, I should have been clearer. What I have is:


<form>
<div style="height: 30%; width: 100%; overflow: auto;">
data line 1
data line 2
data line 3
...
data line N
</div>
<div style="height: 30%; width: 100%; overflow: auto;">
data line 1
...
data line N
</div>
</form>

The desired result is two scrollboxes inside the form. But Moz/N6.2 on most OSes doesn't display what's in the divs at all. IE5.5 handles it fine, and it seems to be valid html/css. If you remove the form tags, the divs work fine. If you remove the overflow and height attributes, the divs work fine even inside the form tags. But I need the multiple scrollboxes inside the form tags. If I can't get it working across the major browser/OS combinations, I'll just have to go back to having extremely long pages.

Thanks for reading!
Christina

Christina

9:09 pm on Sep 3, 2002 (gmt 0)



I tried overflow: scroll - got the same result.

Nick_W

9:10 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay,

Why do you need it inside a form? Why not have it outside of the form tags? It's not part of an input or anything right?

Nick

Christina

9:13 pm on Sep 3, 2002 (gmt 0)



Hi Nick,

Yes - the lines inside the divs have checkboxes - the user needs to be able to select rows from any of the div sets (so the form tags have to go outside of all of the divs) and then submit to another form.

Christina

Nick_W

9:24 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ahhhh... sorry, I missed that.

Well, I'm sorry to say that I'm stumped.

Here's a thought though:

Why not break this long form up with <fieldset> and <legend> tags to group the different groups of data?

If you style these elecments you can make very attractive forms with nicely segmented areas, making them more useable and accessible.

Just a thought ;)

Nick

bobriggs

9:29 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I tried the same code, and it works if I use something like this:

<div style="height: 80px; width: 50%; overflow: scroll; clip:rect(0,0,0,0);">

Note that I couldn't use a percentage on the height.

bird

9:30 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Specifying the height of elements in percent is very tricky in Mozilla. If you want to stay on the safe side, it's usually better to avoid it. Try one of those instead:

<div style="width: 50%; height: 70px; overflow: auto;">
<div style="width: 50%; height: 4em; overflow: auto;">

What happens otherwise, is that Mozilla will simply collapse your div to zero pixels height, as it doesn't have a directly surrounding block element with a fixed height. The next parent block is the form, and without a height specification, that one will be treated as "dynamic" in height. Ultimately this might be a bug, but the browser doesn't seem to be able to take a percentage of that dynamic value.

Btw: If you leave the overflow:auto away, even funnier things will happen... ;)

Nick_W

9:34 pm on Sep 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good ideas!

I didn't think of trying the height ;)

Nick

Christina

9:41 pm on Sep 3, 2002 (gmt 0)



Oh thank you, thank you! (You just don't know how long I've been banging my head on this...) That fixed it!

Happy happy happy! :)
Christina