I have another issue with this hide and show
basically i need to adapt this code elsewhere and need to incorporate this in another page with many form elements & table tags and i get this error
<P>
"Script is not an object or not defined" at this line
var obj=document.all[name]; <--
<P>
Can you help and tell me why?
is there another way to write these two lines var obj=document.all[name];
obj.style.display=obj.style.display=="none"?"":"none";
'*****************THIS WORKS IF PLACED IN A PAGE WITHOUT ANY OTHER FORM ELEMENTS*******************
<%@ Language=VBScript %>
<HTML>
<%
Dim conn
Dim rs
Dim ObjConn
Dim SSQL
Set ObjConn = CreateObject("ADODB.connection"
Set rs = CreateObject("ADODB.recordset"
conn = "Provider=SQLOLEDB.1;Password=cont;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=TEST"
ObjConn.Open conn
SSQL = "select * from customers"
Rs.Open SSQL, ObjConn
%>
<body>
<script language="javascript">
function showLine(name)
{
var obj=document.all[name];
obj.style.display=obj.style.display=="none"?"":"none";
}
function showAll(maxNr,show)
{
for(i=1;i<=maxNr;i++)
{
var obj=document.all["lin_"+i];
obj.style.display=show?"":"none";
}
}
</script>
Show All <input onclick="showAll(<%=rs.RecordCount%>,this.checked) " type="checkbox" ID="Checkbox1" NAME="Checkbox1"><br>
<table border="1" ID="Table1">
<tr>
<td>Name</td>
<td>Show</td>
</tr>
<%
i=0
while not rs.Eof
i=i+1
%>
<tr style="">
<td><%=rs.fields("Companyname"%></td>
<td><input onclick="showLine('lin_<%=i%>')" type="checkbox" ID="Checkbox1" NAME="Checkbox1"></td>
</tr>
<tr id=lin_<%=i%> name=lin_<%=i%> style="display:none">
<td colspan=2>
<%=rs.fields("customerID"%>
</td>
</tr>
<%
rs.MoveNext
wend
%>
</table>
</body>
</HTML>
</HTML>
basically i need to adapt this code elsewhere and need to incorporate this in another page with many form elements & table tags and i get this error
<P>
"Script is not an object or not defined" at this line
var obj=document.all[name]; <--
<P>
Can you help and tell me why?
is there another way to write these two lines var obj=document.all[name];
obj.style.display=obj.style.display=="none"?"":"none";
'*****************THIS WORKS IF PLACED IN A PAGE WITHOUT ANY OTHER FORM ELEMENTS*******************
<%@ Language=VBScript %>
<HTML>
<%
Dim conn
Dim rs
Dim ObjConn
Dim SSQL
Set ObjConn = CreateObject("ADODB.connection"
Set rs = CreateObject("ADODB.recordset"
conn = "Provider=SQLOLEDB.1;Password=cont;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=TEST"
ObjConn.Open conn
SSQL = "select * from customers"
Rs.Open SSQL, ObjConn
%>
<body>
<script language="javascript">
function showLine(name)
{
var obj=document.all[name];
obj.style.display=obj.style.display=="none"?"":"none";
}
function showAll(maxNr,show)
{
for(i=1;i<=maxNr;i++)
{
var obj=document.all["lin_"+i];
obj.style.display=show?"":"none";
}
}
</script>
Show All <input onclick="showAll(<%=rs.RecordCount%>,this.checked) " type="checkbox" ID="Checkbox1" NAME="Checkbox1"><br>
<table border="1" ID="Table1">
<tr>
<td>Name</td>
<td>Show</td>
</tr>
<%
i=0
while not rs.Eof
i=i+1
%>
<tr style="">
<td><%=rs.fields("Companyname"%></td>
<td><input onclick="showLine('lin_<%=i%>')" type="checkbox" ID="Checkbox1" NAME="Checkbox1"></td>
</tr>
<tr id=lin_<%=i%> name=lin_<%=i%> style="display:none">
<td colspan=2>
<%=rs.fields("customerID"%>
</td>
</tr>
<%
rs.MoveNext
wend
%>
</table>
</body>
</HTML>
</HTML>