Click to See Complete Forum and Search --> : Need to hide select box ASAP
trsands
01-11-2004, 03:10 AM
My script creates a select using the followig code:
<td colspan="3" rowspan="3" valign="top"><font face="Courier" size="4">
<select name="selChoices" size="10" id="selChoices">
</select>
</font></td>
How do I get the select hide/show at will?
I tried
document.forms["entry"].selChoices.style.visibility = "hidden"
but that does not work.
What is the property for controlling visible/hidden?
Pittimann
01-11-2004, 03:59 AM
Hi!
The property is "hidden".
Are you sure, your <select> is inside a form and the form's name attribute is "entry"???
Cheers - Pit
fredmv
01-11-2004, 08:31 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
<script type="text/javascript">
//<![CDATA[
function toggle(e)
{
e.style.visibility = e.style.visibility == 'visible' ? 'hidden' : 'visible';
}
onload = function()
{
document.forms[0][0].style.visibility = 'visible';
}
//]]>
</script>
</head>
<body>
<form action="#" onsubmit="return start();">
<div>
<select>
<option>foo</option>
<option>bar</option>
</select>
<input type="button" value="toggle visibility" onclick="toggle(elements[0]);" />
</div>
</form>
</body>
</html>
trsands
01-12-2004, 10:01 AM
This is the relevant code with parts cut out. The error I get is visibility property not found.
Help
<html>
<head>
<title>Play</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" >
<!--
var strlist = new Array();
function hidesel()
{
document.forms["entry"].selChoices.style.visibility = 'hidden ';
}
// Create String
// frm.testfield.value = "creating string";
strlist[strlist.length] = rgstr + " " + bpadit(frm.fldChoice.value,6) + lpadit(frm.fldAmount.value,8) + " " +
frm.selBox[frm.selBox.selectedIndex].text;
frm.selChoices[frm.selChoices.length] = new Option(strlist[strlist.length-1],strlist[strlist.length-1]);
} //show choices
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body background="playbg.png" onLoad="hidesel()">
<form name="entry" >
<p>
<tr>
<td height="19"> </td>
<td> </td>
<td> </td>
<td> </td>
<td width="145"> </td>
<td> </td>
<td rowspan="2" valign="bottom"><input type="button" name="btNext" value="NEXT" onClick="showchoices()"></td>
</tr>
face="Courier" size="4">
<select name="selChoices" size="10" id="selChoices">
</select>
</font></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="95"></td>
<td> </td>
<td> </td>
<td rowspan="2"><input type="button" name="Submit" value="DONE"></td>
</tr>
<tr>
<td height="37"></td>
<td> </td>
<td valign="top"></td>
</tr>
</table>
</form>
</body>
</html>
Pittimann
01-12-2004, 10:16 AM
Hi!
Apart from other things (examples: in the body - face="Courier" size="4"> - in the script } which doesn't belong there or is missing something before it...), your line:
document.forms["entry"].selChoices.style.visibility = 'hidden ';
has a space inside the = 'hidden ' - solution: delete the space...
Cheers - Pit