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

DIV tags

Status
Not open for further replies.
Apr 27, 1999
705
US


Hi,

Does anybody know why a DIV tag like this:

<div style=&quot;position:absolute; left:200&quot;>

renders the form useless? If I remove the <div> tag it works fine. Thanks.

fengshui1998


<html><head>
<title>test</title>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>


</head>
<body>
<div style=&quot;position:absolute; left:200&quot;>
<form method=&quot;post&quot; action=&quot;paging.asp&quot; name=&quot;form1&quot;>

<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;1&quot; >
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;2&quot; >
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;3&quot;>

<input type=&quot;button&quot; value=&quot;press&quot; onclick=&quot;check()&quot;>

</form>
</div>
</body>
<script language=&quot;javascript&quot;>
function check()
{
var lenRad = document.form1.r1.length;
alert(lenRad);
if (document.form1.r1.checked == true)
{document.form1.r2.checked = true}

}

</script>
</html>
 
what do you mean, &quot;renders the form useless&quot; ???
do you mean :
- my javascript doesn't work ?
this is because you're looking for : document.form1 but form1 is INSIDE the div - so, name the div and change adresses to document.divname.form1
- the form displays ugly ?
this is because of the absolute positionning ;]]
 
iza,

Thanks for your response! The form I used was just for testing, that's why it's &quot;ugly&quot;. I just wanted to get down to the basics so I could try to determine what was going on. I'll try your answer. Thanks!

Fengshui1998
 
iza,

I tried your suggestion. Still does not work. Any ideas?

<html><head>
<title>test</title>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>
<!-- #include file=&quot;adovbs.inc&quot; -->
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles/default.css&quot;>
</head>
<body>

<div id=&quot;d1&quot;>
<form name=&quot;form1&quot;>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;1&quot;>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;2&quot;>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;3&quot;>
<input type=&quot;button&quot; value=&quot;press&quot; onclick=&quot;check()&quot;>
</form>
</div>

</body>

<script language=&quot;javascript&quot;>
function check()
{
var lenRad = document.d1.form1.r1.length;
alert(lenRad);
}
</script>
</html>
 
what is not working exactly ?

if you're using netscape, ABSOLUT position the div - or else it won't find it <div id=d1 STYLE=&quot;position:absolute>

for Netscape the general way to access div is like this: document.d1 or document.layers[&quot;d1&quot;]

for Internet Explorer it's: d1 or document.all[&quot;d1&quot;]
 
iza,
I tried your solution as below into test.htm, still does not work. can you copy this page and try it? Or do you have anything that is working for Netscape? Thanks

Fengshui1998


<html><head>
<title>test</title>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>
<!-- #include file=&quot;adovbs.inc&quot; -->
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles/default.css&quot;>
</head>
<body>
<div style=&quot;position:absolute; left:180&quot; id=&quot;d1&quot;>
<form name=&quot;form1&quot;>

<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;1&quot;>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;2&quot;>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;3&quot;>
<input type=&quot;button&quot; value=&quot;press&quot; onclick=&quot;check()&quot;>
</form>
</div>
</body>

<script language=&quot;javascript&quot;>
function check()
{
var lenRad = document.layers[&quot;d1&quot;].form1.r1.length;
alert(lenRad);
}

</script>
</html>
 
i don't have netscape right now
and as long as you don't tell me WHAT is not working i can't help you - maybe you're correctly adressing the form, but the radiobutton.lenght is not working !!!
so try yourself this :
function check()
{
alert(document.layers[&quot;d1&quot;])
// should be [object]
alert(document.layers[&quot;d1&quot;].form1)
// should be [object]
alert(document.layers[&quot;d1&quot;].form1.r1)
// should be [object]
alert(document.layers[&quot;d1&quot;].form1.r1.length)
// should be an int
var lenRad = document.layers[&quot;d1&quot;].form1.r1.length;
}



 
iza,

I incorporated your code into test.htm. The first object returned is &quot;layers&quot; and that is fine. But it cannot locate document.layers[&quot;d1&quot;].form1. It returns &quot;undefined&quot;. Subsequently it cannot return the value of the number of radio buttons. ?????? Thanks for all your help, but this should be real simple.

Just to let you know, I also heard that Netscape will be doing away with document.layers in the future.

Fengshui1998
 
geeeee missed one &quot;document&quot;
document.layers[&quot;d1&quot;].document..form1

thank you vituz :)))))
 


Many, many thanks to you iza and vituz! Finally it worked, but I hate the solution!!

Fengshui1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top