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

SHow and hide elements

Status
Not open for further replies.

Sammy145

Programmer
Oct 4, 2002
173
GB
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>
&quot;Script is not an object or not defined&quot; 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==&quot;none&quot;?&quot;&quot;:&quot;none&quot;;

'*****************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(&quot;ADODB.connection&quot;)
Set rs = CreateObject(&quot;ADODB.recordset&quot;)
conn = &quot;Provider=SQLOLEDB.1;Password=cont;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=TEST&quot;
ObjConn.Open conn

SSQL = &quot;select * from customers&quot;
Rs.Open SSQL, ObjConn
%>

<body>
<script language=&quot;javascript&quot;>
function showLine(name)
{
var obj=document.all[name];
obj.style.display=obj.style.display==&quot;none&quot;?&quot;&quot;:&quot;none&quot;;
}
function showAll(maxNr,show)
{
for(i=1;i<=maxNr;i++)
{
var obj=document.all[&quot;lin_&quot;+i];
obj.style.display=show?&quot;&quot;:&quot;none&quot;;
}
}
</script>
Show All <input onclick=&quot;showAll(<%=rs.RecordCount%>,this.checked) &quot; type=&quot;checkbox&quot; ID=&quot;Checkbox1&quot; NAME=&quot;Checkbox1&quot;><br>
<table border=&quot;1&quot; ID=&quot;Table1&quot;>
<tr>
<td>Name</td>
<td>Show</td>
</tr>
<%
i=0
while not rs.Eof
i=i+1
%>
<tr style=&quot;&quot;>
<td><%=rs.fields(&quot;Companyname&quot;)%></td>
<td><input onclick=&quot;showLine('lin_<%=i%>')&quot; type=&quot;checkbox&quot; ID=&quot;Checkbox1&quot; NAME=&quot;Checkbox1&quot;></td>
</tr>
<tr id=lin_<%=i%> name=lin_<%=i%> style=&quot;display:none&quot;>
<td colspan=2>
<%=rs.fields(&quot;customerID&quot;)%>
</td>
</tr>
<%
rs.MoveNext
wend
%>
</table>
</body>
</HTML>

</HTML>
 
I'm not sure if you can do that with table rows. Try placing the customerID in a div and name the div instead of the row.

ASCII silly question, get a silly ANSI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top