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

CSS and DIV positioning of form elements 1

Status
Not open for further replies.

BDNFLNC

Technical User
May 30, 2002
202
US
Hey all...
I have this form that someone asked me to help with. If you view the page at you will see my issue.

I want the form elements to show up in the same place each time. Currently they are showing up below each other. I am not skilled enough in CSS positioningto do this right.

Any help is appreciated.

<html>
<title></title>
<head>
<script>
ns4 = (document.layers) ? true:false
ie4 = (document.all) ? true:false
ng5 = (document.getElementById) ? true:false

function hideSec() {
if (ng5) document.getElementById('sec1').style.visibility = &quot;hidden&quot;
else if (ns4) document.sec1.visibility = &quot;hide&quot;
else if (ie4) sec1.style.visibility =&quot;hidden&quot;

if (ng5) document.getElementById('sec2').style.visibility = &quot;hidden&quot;
else if (ns4) document.sec2.visibility = &quot;hide&quot;
else if (ie4) sec2.style.visibility =&quot;hidden&quot;

if (ng5) document.getElementById('sec3').style.visibility = &quot;hidden&quot;
else if (ns4) document.sec3.visibility = &quot;hide&quot;
else if (ie4) sec3.style.visibility =&quot;hidden&quot;
}
function showSec(n) {
hideSec();
if (ng5) document.getElementById('sec' + n).style.visibility = &quot;visible&quot;;
else if (ns4) document.layers[&quot;sec&quot; + n].visibility = &quot;show&quot;;
else if (ie4) document.all[&quot;sec&quot; + n].style.visibility = &quot;visible&quot;;
}
</script>
</head>
<body onload=&quot;hideSec()&quot;>
<a href=&quot;JavaScript:showSec(1)&quot;>Search by Lab</a>   
<a href=&quot;JavaScript:showSec(2)&quot;>Search by Model</a>   
<a href=&quot;JavaScript:showSec(3)&quot;>Search by Type</a>   


<div ID=&quot;sec1&quot; {position: absolute; top: 175px; left:235px;visibility:hidden; z-index: -1;}>
<form method=&quot;post&quot; action=&quot;searchModels.asp&quot;>
Search by Lab<input type=&quot;text&quot; name=&quot;Lab&quot;>
<input type=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</div>

<div ID=&quot;sec2&quot; {position: absolute; top: 175px; left:235px;visibility:hidden; z-index: -2;}>
<form method=&quot;post&quot; action=&quot;searchModels.asp&quot;>
Search by Model<input type=&quot;text&quot; name=&quot;Name&quot;>
<input type=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</div>

<div ID=&quot;sec3&quot; {position: absolute; top: 175px; left:235px;visibility:hidden; z-index: -3;}>
<form method=&quot;post&quot; action=&quot;searchModels.asp&quot;>
Search by Type<input type=&quot;text&quot; name=&quot;Type&quot;>
<input type=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</div>

</body>
</html>
 
Try using more standard CSS syntax ie

Code:
<div ID=&quot;sec3&quot; style=&quot;position: absolute; top: 175px; left:235px;visibility:hidden; z-index: -3;&quot;>

rather than

Code:
<div ID=&quot;sec3&quot; {position: absolute; top: 175px; left:235px;visibility:hidden; z-index: -3;}>
<form method=&quot;post&quot; action=&quot;searchModels.asp&quot;>

This should fix things (you will prob have to tweak your positioning coords)

hope it helps
 
Perfect answer gollyg!

I should have seen that the style wasn't actually ON the DIV.

Now I know why everyone gives me these problems to solve. Tek-tips makes me look pretty good sometimes! Heck, I even tell them where I get teh answers!

Thanks a bunch.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top