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!

Select in Layer tag not appearing properly 2

Status
Not open for further replies.

wood

MIS
Aug 3, 2000
139
CA
I have the following code:

...
<table>
<tr>

<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;><b>Frequency of Report:</b></font>
</td>

<td align=&quot;left&quot;>
<select name=&quot;RptFreq&quot; onChange=&quot;listOptions(this.form)&quot;>
<option value=&quot;*WEEKLY&quot;>Weekly</option>
<option value=&quot;*MONTHLY&quot; selected>Monthly</option>
</select>
</td>
</tr>

<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;><b>Scheduled Day:</b></font>
</td>
<td align=&quot;left&quot;>
<select name=&quot;SchDay&quot;>
<option value=&quot;*MON&quot;>Monday</option>
<option value=&quot;*TUE&quot;>Tuesday</option>
<option value=&quot;*WED&quot;>Wednesday</option>
<option value=&quot;*THU&quot;>Thursday</option>
<option value=&quot;*FRI&quot;>Friday</option>
<option value=&quot;*NONE&quot;>None</option>
</select>
</td>
</tr>

<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;><b>Relative Day:</b></font>
</td>
<td align=&quot;left&quot;>
<ilayer name=&quot;LastSelect&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</ilayer>
</td>
</tr>
</table>
...

What I am doing is having a layer so that I can make it visible/invisible based on the first select box. The code to make it visible/invisible works fine in both IE and NS.

The problem is that in NS the select doesn't show as a dropdown box. It just displays the text values in the options. It displays: &quot;*LAST 1 2 3 4 5&quot;, as text. In IE there is no problem.

Does anyone have any ideas?
 
Can you not just do this:

<td align=&quot;left&quot; style=&quot;display:none;&quot; id=secondSelect>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</td>


and change the secondSelect.style.display = 'block' when you want to show what was the layer? &quot;A computer scientist is a person who knows when it is time to hit the computer.&quot;

John

johnmc@mvmills.com
 
This works great for IE, but how do I reference the display property in NS?

 
Thanks, vituz, but that doesn't really apply. I have checked out the following link, and this didn't work either.


I get the error, secondSelect not defined. However, I do have a div with the id and name secondSelect.

Any other ideas?
 
hie
culd u plz show me ur last code? (with those link's fixes) regards, vic
 
Please note that I have added another select box, so it is now called thirdSelect and not secondSelect.

here is the code

function listOptions(formobj){
//Check the browser version.
if (navigator.appName==&quot;Netscape&quot;){
var browser=&quot;ns&quot;;
}
else {
var browser=&quot;ie&quot;;
}

var optchosen=document.reports.RptFreq.value
if (optchosen!=&quot;*MONTHLY&quot;) {
//weekly
//hide the last select box.
if (browser==&quot;ns&quot;){
document.thirdSelect.visibility = 'hide'
}
else{
document.all.thirdSelecttb.style.display = 'none'
}
}
else {
//monthly
//show the last select box.
if (browser==&quot;ns&quot;){
document.thirdSelect.visibility = 'show'
}
else{
document.all.thirdSelecttb.style.display = 'block'
}
}
}

and the select is in a table as so:

...
<td align=&quot;left&quot; style=&quot;display:block;&quot; id=&quot;thirdSelecttb&quot; name=&quot;thirdSelecttb&quot;>
<div style=&quot;display:block;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</div>
</td>
...
 
just from the first look i can say what's wrong:
if u'll go 2 & check it out, u'll c that &quot;For Netscape, forms and layers don't work so well together. Again since Netsape layers are essentially a whole different document, a form ...&quot;
& u have the followin:
<div style=&quot;display:block;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<select name=&quot;RelDay&quot;>
...
wrong for netscape..

now about showin/hidin:
this is a workable syntax, i think:
function show(id) {
if (ns4) document.layers[id].visibility = &quot;show&quot;
else if (ie4) document.all[id].style.visibility = &quot;visible&quot;
}

function hide(id) {
if (ns4) document.layers[id].visibility = &quot;hide&quot;
else if (ie4) document.all[id].style.visibility = &quot;hidden&quot;
}
(from ur link but not urs..

sorry, now i gotta go, may be someone else today will help u; if not - c ya tomorrow.. regards, vic
 
I have modified my code to the following and I now get the error &quot;document.layers.thirdSelect has no properties.&quot;

function listOptions(formobj){
//Check the browser version.
if (navigator.appName==&quot;Netscape&quot;){
var browser=&quot;ns&quot;;
}
else {
var browser=&quot;ie&quot;;
}

var optchosen=document.reports.RptFreq.value
if (optchosen!=&quot;*MONTHLY&quot;) {
//weekly
//hide the last select box.
if (browser==&quot;ns&quot;){
document.layers[&quot;thirdSelect&quot;].visibility = &quot;hide&quot;
}
else{
document.all.thirdSelecttb.style.display = 'none'
}
}
else {
//monthly
//show the last select box.
if (browser==&quot;ns&quot;){
document.layers[&quot;thirdSelect&quot;].visibility = 'show'
}
else{
document.all.thirdSelecttb.style.display = 'block'
}
}
}

and the select in the table is now like so (with the form):

...
<td align=&quot;left&quot; style=&quot;display:block;&quot; id=&quot;thirdSelecttb&quot; name=&quot;thirdSelecttb&quot;>
<div style=&quot;display:block;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<form name=&quot;form2&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
</div>
</td>
...

Anyone have other ideas?

I really appreciate your help so far!
 
hie woody, u're still here?
sorry, forgot 2 tell u: in netscape u have 2 set position property for layer (absolute or relative) thy means <div style=&quot;position:relative; display:block;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>

but i am afraid that u also have 2 set layer's width or clip it 2 width u need.. 'coz there is (are) smth in netscrap that prevents us from pleasant coding.. :-(
so, 2 set layers width u'll have 2 define a style for it in ur style tag or in separate css or u culd use <ilayer><layer><div> construction.. if u wont get it 2 work just tell me, i'll write an example for ya
regards, vic
 
I tried adding the position relative and absolute and both times the contents of the div disappear.

Here is what I have:

<div style=&quot;position:absolute;display:block;width:150;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;
<form name=&quot;form2&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
</div>

 
did u uploaded it somewhere?
if u did, plz give me the url
or else paste here minimal document (complete html document with forms, divs, scripts, i mean with all that is about our subject - i'm just 2 lazy 2 write all of it out myself.. ;-)) i'll c what can i do for u.. regards, vic
 
Try this. It works only in Netscape.


<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
<script language=&quot;javascript&quot;>
function showIt(layerName)
{
document.layers[layerName].visibility = &quot;show&quot;;
}
</script>
</HEAD>
<BODY>
<form name=&quot;frmTest&quot;>
<INPUT type=&quot;button&quot; value=&quot;Button&quot; id=button1 name=button1 onClick=&quot;showIt('thirdSelect')&quot;>
</form>
<div style=&quot;position:absolute;display:block;width:150;visibility:hidden;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<form name=&quot;form2&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
</div>


</BODY>
</HTML>
 
Here is the complete page:

<html>
<head>

<script>

function listOptions(formobj){
//Check the browser version.
if (navigator.appName==&quot;Netscape&quot;){
var browser=&quot;ns&quot;;
}
else {
var browser=&quot;ie&quot;;
}

//If Option is Monthly, display the third select box, and remove the option *All from the 2nd select box.

var optchosen=document.reports.RptFreq.value
if (optchosen!=&quot;*MONTHLY&quot;) {
//weekly
//hide the last select box.
if (browser==&quot;ns&quot;){
document.layers[&quot;thirdSelect&quot;].visibility = &quot;hide&quot;
}
else{
document.all.thirdSelecttb.style.display = 'none'
}
}
else {
//monthly
//show the last select box.
if (browser==&quot;ns&quot;){
document.layers[&quot;thirdSelect&quot;].visibility = 'show'
}
else{
document.all.thirdSelecttb.style.display = 'block'
}
}
}
</script>

</head>

<body>
<div align=&quot;center&quot;><center>

<br>

<form name=&quot;reports&quot; method=&quot;post&quot; action=&quot;scheduler&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<table>
<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<b>Frequency of Report:</b>
</font>
</td>
<td align=&quot;left&quot;>
<select name=&quot;RptFreq&quot; onChange=&quot;listOptions(this.form)&quot;>
<option value=&quot;*WEEKLY&quot;>Weekly</option>
<option value=&quot;*MONTHLY&quot; selected>Monthly</option>
</select>
</td>
</tr>
<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<b>Scheduled Day:</b>
</font>
</td>
<td align=&quot;left&quot;>
<select name=&quot;SchDay&quot;>
<option value=&quot;*MON&quot;>Monday</option>
<option value=&quot;*TUE&quot;>Tuesday</option>
<option value=&quot;*WED&quot;>Wednesday</option>
<option value=&quot;*THU&quot;>Thursday</option>
<option value=&quot;*FRI&quot;>Friday</option>
<option value=&quot;*NONE&quot;>None</option>
</select>
</td>
</tr>
<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<b>Relative Day:</b>
</font>
</td>
<td align=&quot;left&quot; style=&quot;display:block;&quot; id=&quot;thirdSelecttb&quot; name=&quot;thirdSelecttb&quot;>
<div style=&quot;position:absolute;display:block;width:150&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<form name=&quot;form2&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
</div>
</td>
</tr>
</table>
</font>

<input type=&quot;hidden&quot; name=&quot;RelativeDay&quot; value=&quot;&quot;>

</form>
</body>
</html>
 
I could be wrong but I think I found your problem. I don't think Netscape likes the use of nested forms but don't quote me on that.
 
Mithrihall,

The code you gave hides the layer to start. How do I show the layer when the page is first loaded?

I have tried &quot;visibility:visible&quot;, but I don't think that that is the right syntax.
 
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
<script language=&quot;javascript&quot;>
function showIt(layerName)
{
if (document.getElementById)
document.getElementById(layerName).style.visibility = &quot;hidden&quot;;
else
document.layers[layerName].visibility = &quot;hidden&quot;;
}
</script>
</HEAD>
<BODY>
<form name=&quot;frmTest&quot;>
<INPUT type=&quot;button&quot; value=&quot;Button&quot; id=button1 name=button1 onClick=&quot;showIt('thirdSelect')&quot;>
</form>
<BR>
<BR>
<div style=&quot;position:absolute;display:block;width:150;visibility:visible;&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<form name=&quot;form2&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
</div>


</BODY>
</HTML>
 
Mithrilhall,

You were right, I did have to get rid of the nested forms. The code now looks like above.

Now Once I have it hidden (that works okay), I need to show it again. Here are the two funtions I have:

function showIt(layerName)
{
if (document.getElementById){
document.getElementById(layerName).style.visibility = &quot;show&quot;;}
else {
document.layers[layerName].visibility = &quot;show&quot;;}
}

function hideIt(layerName)
{

if (document.getElementById){
document.getElementById(layerName).style.visibility = &quot;hidden&quot;;}
else{
document.layers[layerName].visibility = &quot;hidden&quot;;}
}

The hideIt function works great, but the showIt function is not working, and I don't get any error messages.

Any ideas?
 
Try this:

function showIt(layerName)
{
if (document.getElementById){
document.getElementById(layerName).style.visibility = &quot;visible&quot;;}
else {
document.layers[layerName].visibility = &quot;show&quot;;}
}
 
Thanks, but that didn't work either. I am including the current code that I have. The hide works okay, but the show doesn't.

<html>
<head>

<script>

function showIt(layerName){
if (document.getElementById){
document.getElementById(layerName).style.visibility = &quot;visible&quot;;
}
else {
document.layers[layerName].visibility = &quot;show&quot;;
}
}

function hideIt(layerName){
if (document.getElementById){
document.getElementById(layerName).style.visibility = &quot;hidden&quot;;
}
else{
document.layers[layerName].visibility = &quot;hidden&quot;;
}
}

function listOptions(formobj){
//Check the browser version.
if (navigator.appName==&quot;Netscape&quot;){
var browser=&quot;ns&quot;;
}
else {
var browser=&quot;ie&quot;;
}

var optchosen=document.reports.RptFreq.value
if (optchosen!=&quot;*MONTHLY&quot;) {
//weekly
//hide the last select box.
if (browser==&quot;ns&quot;){
hideIt('thirdSelect')
}
else{
document.all.thirdSelecttb.style.display = 'none'
}
}
else {
//monthly
//show the last select box.
if (browser==&quot;ns&quot;){
showIt('thirdSelect')
}
else{
document.all.thirdSelecttb.style.display = 'block'
}
}
}
</script>

</head>

<body>

<br>

<form name=&quot;reports&quot; method=&quot;post&quot; action=&quot;scheduler&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<table>
<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<b>Frequency of Report:</b>
</font>
</td>
<td align=&quot;left&quot;>
<select name=&quot;RptFreq&quot; onChange=&quot;listOptions(this.form)&quot;>
<option value=&quot;*WEEKLY&quot;>Weekly</option>
<option value=&quot;*MONTHLY&quot; selected>Monthly</option>
</select>
</td>
</tr>
<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<b>Scheduled Day:</b>
</font>
</td>
<td align=&quot;left&quot;>
<select name=&quot;SchDay&quot;>
<option value=&quot;*MON&quot;>Monday</option>
<option value=&quot;*TUE&quot;>Tuesday</option>
<option value=&quot;*WED&quot;>Wednesday</option>
<option value=&quot;*THU&quot;>Thursday</option>
<option value=&quot;*FRI&quot;>Friday</option>
<option value=&quot;*NONE&quot;>None</option>
</select>
</td>
</tr>
<input type=&quot;hidden&quot; name=&quot;RelativeDay&quot; value=&quot;&quot;>
</form>
<tr>
<td align=&quot;right&quot;>
<font face=&quot;arial&quot; size=&quot;2&quot; color=&quot;black&quot;>
<b>Relative Day:</b>
</font>
</td>
<td align=&quot;left&quot; style=&quot;display:block;&quot; id=&quot;thirdSelecttb&quot; name=&quot;thirdSelecttb&quot;>
<div style=&quot;position:relative;display:block;width:250;visibility:visible&quot; id=&quot;thirdSelect&quot; name=&quot;thirdSelect&quot;>
<form name=&quot;form2&quot;>
<select name=&quot;RelDay&quot;>
<option value=&quot;*LAST&quot; selected>Last</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
</div>
</td>
</tr>
</table>

</font>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top