Connecting Tech Pros Worldwide Forums | Help | Site Map

Why is this doing that?

Ed Jay
Guest
 
Posts: n/a
#1: Nov 23 '05
Well, nobody in alt.html wants to answer this question, so I'll ask it
here:

I have a button and associated text in a container. When one clicks the
button it brings up additional buttons and text in a container to the
right of the first container. I get more than I bargained for...it also
brings up unwanted space below the dual container line. I can't figure out
why, so I can't fix it.

If you go to <http://www.edbj.aes-intl.com/brcaform1.html> and click on
'Patient is symptomatic of breast disease:' you'll observe the errant
behavior.

Basically, the markup and code is:

<Form....>
<div style="float:right">
Patient is symptomatic of breast disease :
<checkbox... onClick="show additional text">
<div id='div1' onClick="show more text below>
</div></div>
</Form>

<br clear=all><br>Show the next text block independent of the above>

--
Ed Jay (remove M to respond by email)

Joshie Surber
Guest
 
Posts: n/a
#2: Nov 23 '05

re: Why is this doing that?


> it also brings up unwanted space below the dual container line

Try setting the margin-bottom (or padding-bottom) on whatever is being
toggled; what is happening is you are making stuff appear with a bottom
margin/padding.

Simple.

Evertjan.
Guest
 
Posts: n/a
#3: Nov 23 '05

re: Why is this doing that?


Ed Jay wrote on 12 nov 2005 in comp.lang.javascript:
[color=blue]
> Well, nobody in alt.html wants to answer this question, so I'll ask it
> here:
>
> I have a button and associated text in a container. When one clicks
> the button it brings up additional buttons and text in a container to
> the right of the first container. I get more than I bargained for...it
> also brings up unwanted space below the dual container line. I can't
> figure out why, so I can't fix it.
>
> If you go to <http://www.edbj.aes-intl.com/brcaform1.html> and click
> on 'Patient is symptomatic of breast disease:' you'll observe the
> errant behavior.
>
> Basically, the markup and code is:
>
> <Form....>
> <div style="float:right">
> Patient is symptomatic of breast disease :
> <checkbox... onClick="show additional text">
> <div id='div1' onClick="show more text below>
> </div></div>
> </Form>
>
> <br clear=all><br>Show the next text block independent of the above>
>[/color]

do not use float here, change it, temporarily adding a border, to:
<div NOstyle="float:left;" style="border:6px solid green;">

and move the end </div> to the group if </div>'s further down.

Then see what happens.

You could change the toggling of:
<div id="div1" style="display:none;border:1px solid black;">
from
target.style.display = "";
meaning target.style.display = "block";
to
target.style.display = "inline";
and see what happens

Adding inlines on the right is better than floating the original on the
left, IMHO. Floating is for images in a text, not for this.

===========================================

A better way, detecting the checkbox state, is:

function toggle(what,targetId) {
target = document.getElementById(targetId);
target.style.display=(what.checked)?'inline':'none ';
}

and

<input type=checkbox onClick="toggle(this,'div1')">



--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Ed Jay
Guest
 
Posts: n/a
#4: Nov 23 '05

re: Why is this doing that?


"Joshie Surber" <joshiesurber@gmail.com> wrote:
[color=blue][color=green]
>> it also brings up unwanted space below the dual container line[/color]
>
>Try setting the margin-bottom (or padding-bottom) on whatever is being
>toggled; what is happening is you are making stuff appear with a bottom
>margin/padding.
>
>Simple.[/color]

Simple, but not the answer. Proven empirically.

--
Ed Jay (remove M to respond by email)
Ed Jay
Guest
 
Posts: n/a
#5: Nov 23 '05

re: Why is this doing that?


"Evertjan." <exjxw.hannivoort@interxnl.net> wrote:
[color=blue]
>Ed Jay wrote on 12 nov 2005 in comp.lang.javascript:
>[color=green]
>> I have a button and associated text in a container. When one clicks
>> the button it brings up additional buttons and text in a container to
>> the right of the first container. I get more than I bargained for...it
>> also brings up unwanted space below the dual container line. I can't
>> figure out why, so I can't fix it.
>>
>> If you go to <http://www.edbj.aes-intl.com/brcaform1.html> and click
>> on 'Patient is symptomatic of breast disease:' you'll observe the
>> errant behavior.
>>
>> Basically, the markup and code is:
>>
>> <Form....>
>> <div style="float:right">
>> Patient is symptomatic of breast disease :
>> <checkbox... onClick="show additional text">
>> <div id='div1' onClick="show more text below>
>> </div></div>
>> </Form>
>>
>> <br clear=all><br>Show the next text block independent of the above>
>>[/color]
>
>do not use float here, change it, temporarily adding a border, to:
><div NOstyle="float:left;" style="border:6px solid green;">[/color]

Doing this caused an extra line to appear below the 'Patient is
symptomatic' line, even when the form box wasn't checked. It also extended
it's container to the right margin. Checking the box displayed 'div1'
immediately below, without adding another blank line.[color=blue]
>
>and move the end </div> to the group if </div>'s further down.
>Then see what happens.[/color]

The only additional change was the inclusion of 'div1' as a subset of the
'Patient is symptomatic' container.[color=blue]
>
>You could change the toggling of:
><div id="div1" style="display:none;border:1px solid black;">
>from
>target.style.display = "";
>meaning target.style.display = "block";
>to
>target.style.display = "inline";
>and see what happens[/color]

No change.[color=blue]
>
>Adding inlines on the right is better than floating the original on the
>left, IMHO. Floating is for images in a text, not for this.
>[/color]
Understood. Thanks for the tip.

Got it working...sort of.

When I removed the float I noted that the primary container extended to
the right margin. It occurred to me that what was possibly happening was
that the hidden text container width plus the primary container width was
causing line wrapping. So, I limited the widths of the two and apparently,
I was correct. Toggling 'div1' stopped adding an extra blank line.
However, with the float gone, I was still introducing a blank line, but
it's static. Regardless of whether I used a block or inline style for
'div1'. If I add back the float and limit the width of the sum of the two
containers, it seems to work, whether I use inline or block; however, only
if the float is present.

Changing the above introduces a couple of new issues:

When I select 'Burning, Pain or Numbness,' 'div2' appears as it should,
below 'div1,' but it now introduces an extra blank line below it, even
though I've guaranteed no wrapping by limiting its width.

Further, when one of the choices (left/right/both) is selected in 'div2',
'div3' is displayed but with an extra added line above the text.

I tried adding margin:0px and padding:0px to both 'div2' and 'div3' but to
no avail.

Also, if I don't limit the width of 'div2', I experience the same behavior
as with 'div3.'[color=blue]
>===========================================
>
>A better way, detecting the checkbox state, is:
>
>function toggle(what,targetId) {
> target = document.getElementById(targetId);
> target.style.display=(what.checked)?'inline':'none ';
>}
>
>and
>
><input type=checkbox onClick="toggle(this,'div1')">[/color]

Thanks. Done.

--
Ed Jay (remove M to respond by email)
Joshie Surber
Guest
 
Posts: n/a
#6: Nov 23 '05

re: Why is this doing that?


> Simple, but not the answer. Proven empirically.

Sorry, I didn't have time to test... priority interrupt from the SO.
Sounded good in my head though.

Ed Jay
Guest
 
Posts: n/a
#7: Nov 23 '05

re: Why is this doing that?


"Joshie Surber" <joshiesurber@gmail.com> wrote:
[color=blue][color=green]
>> Simple, but not the answer. Proven empirically.[/color]
>
>Sorry, I didn't have time to test... priority interrupt from the SO.
>Sounded good in my head though.[/color]

No problem. I've employed your fix elsewhere and it's worked fine. :-)

--
Ed Jay (remove M to respond by email)
Ed Jay
Guest
 
Posts: n/a
#8: Nov 23 '05

re: Why is this doing that?


Ed Jay <edMbj@aes-intl.com> wrote:
[color=blue]
>I have a button and associated text in a container. When one clicks the
>button it brings up additional buttons and text in a container to the
>right of the first container. I get more than I bargained for...it also
>brings up unwanted space below the dual container line. I can't figure out
>why, so I can't fix it.
>[/color]
Issue resolved by using visibility:visible/hidden instead of
display:inline/none for the first container, and not including the subset
containers as part of the visibility-controlled container.

The final code is in <www.edbj.aes-intl.com/projform2.html>.

Thanks to everyone for your help. You taught me a lot. :-)

--
Ed Jay (remove M to respond by email)
Closed Thread