Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2007, 12:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default onlick display more colums

How can display more column onclick / button ?

I am using following table to display the employee information.

TABLE cellSpacing=0 cellPadding=0 width="100%" border=1 bordercolor="skyblue">
<tr bgcolor=#76b2f0>
    
     <th bgcolor=#76b2f0><span style="font-weight: 400">
     <em style="font-style: normal"><strong> Name </strong></em></span></th>
     <th bgcolor=#76b2f0><span style="font-weight: 400">
     <em style="font-style: normal"><strong>Position </strong></em></span></th>
    
......
...

</tr>

<%
Dim fielddata
dim v
v = 1

do while rs.eof=false
if v mod 2 = 0 then
Response.Write("<tr bgcolor=#e3effe>")
else
Response.Write("<tr bgcolor=f8f8ff>")

end if

Response.Write("<td align=left>" & rs("Name") & "</td>")
Response.Write("<td align=left>" & rs("POSITION_CODE") & "</td>")
Response.Write("<td align=left>" & rs("DEPARTMENT_CODE") & "</td>")
....
....

v = v + 1
rs.movenext
loop
%>
</table>

mployee table have 35 column, inital we display some important
information of the employee, when we click the button it display
more column, home phone, address, zipcode, courntry etc..?

just like paging, when click, paging dislay more pages.

regards
Mateen
 
Old July 13th, 2007, 02:46 AM
Authorized User
 
Join Date: Jun 2007
Location: Las Vegas, Nevada, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would think you will need to do a postback to accomplish this one. here is how I would do it, although its possable others here may have a better way
<Html>
<script language="VBSCRIPT">
Sub button_OnCLick
form1.hiddenbox.value="1"
form1.submit
End Sub
</Script>

<%Dim fielddata
dim v
v = 1

do while rs.eof=false
if v mod 2 = 0 then
Response.Write("<tr bgcolor=#e3effe>")
else
Response.Write("<tr bgcolor=f8f8ff>")

end if

Response.Write("<td align=left>" & rs("Name") & "</td>")
Response.Write("<td align=left>" & rs("POSITION_CODE") & "</td>")
Response.Write("<td align=left>" & rs("DEPARTMENT_CODE") & "</td>")

'Now at the bottom I would check to see if the button has been clicked i.e. the hidden input box has a value of 1
IF Request.form("Hiddenbox") = "1" Then
'The rest of the Information you want in your table here
End IF
v = v + 1
rs.movenext
loop
%>
 
Old July 16th, 2007, 07:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.
I try above like this.

<table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="33%">
                            <%
set cn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
//cn.ConnectionString=" coonection string "
cn.Open

pn=Request.QueryString("pn")

rs.Open "SELECT EMP_ID,NAME,POSITION_CODE,DEPARTMENT_CODE,DATE_JOI NED,MOBILE,LOCAL_PHONE,ICE_LOCAL_PERSON,HOME_PHONE FROM EMPLOYEE ORDER BY NAME",cn,3,1

rs.PageSize=1000

Response.Write("" & " Total # of Staff " & rs.RecordCount & "")


%>
                          </td>
                          <td width="31%">
</td>
                          <td width="36%">&nbsp;</td>
                        </tr>
                      </table>
                      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=1 bordercolor="skyblue" style="border-collapse:collapse; mso-table-layout-alt:fixed;border:none;mso-border-alt:solid windowtext 1.5pt; mso-padding-alt:0in 5.4pt 0in 5.4pt">
  <tr bgcolor=#76b2f0>

                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> &nbsp;</strong></em></span></th>
                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> Emp No</strong></em></span></th>
<th bgcolor=#76b2f0><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      Name</strong></em></span></th>
<th bgcolor=#76b2f0><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      Position</strong></em></span></th>
                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> Department</strong></em></span></th>
                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> Joining Date</strong></em></span></th>

 </tr>

  <%
Dim fielddata
dim v
v = 1

do while rs.eof=false
if v mod 2 = 0 then
   Response.Write("<tr bgcolor=#e3effe>")
else
   Response.Write("<tr bgcolor=f8f8ff>")

end if


Response.Write("<td><input type=checkbox name=delrec value='" & rs("emp_id") & "' ></td>")

Response.Write("<td align=center>")
Response.Write("<a target=_self title='Select Emp_ID' href='update_emp.asp?empno=" & (rs("emp_id")) & "'>" & rs("emp_id") & "</a>")
Response.Write("</td>")

Response.Write("<td align=left>" & rs("Name") & "</td>")
Response.Write("<td align=left>" & rs("POSITION_CODE") & "</td>")
Response.Write("<td align=left>" & rs("DEPARTMENT_CODE") & "</td>")
Response.Write("<td align=left>" & rs("DATE_JOINED") & "</td>")


IF Request.form("Hiddenbox") = "1" Then
 'The rest of the Information you want in your table here
%>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="33%">
                            <%
set cn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
cn.ConnectionString="//// "
cn.Open

pn=Request.QueryString("pn")


rs2.Open "SELECT EMP_ID,NAME,POSITION_CODE,DEPARTMENT_CODE,DATE_JOI NED,MOBILE,LOCAL_PHONE,ICE_LOCAL_PERSON,HOME_PHONE FROM EMPLOYEE ORDER BY NAME",cn,3,1

rs2.PageSize=1000

Response.Write("" & " Total # of Staff " & rs2.RecordCount & "")


%>
                          </td>
                          <td width="31%">
</td>
                          <td width="36%">&nbsp;</td>
                        </tr>
                      </table>
                      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=1 bordercolor="skyblue" style="border-collapse:collapse; mso-table-layout-alt:fixed;border:none;mso-border-alt:solid windowtext 1.5pt; mso-padding-alt:0in 5.4pt 0in 5.4pt">
  <tr bgcolor=#76b2f0>

                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> &nbsp;</strong></em></span></th>
                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> Mobile No</strong></em></span></th>
<th bgcolor=#76b2f0><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      Local Ph </strong></em></span></th>
<th bgcolor=#76b2f0><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      ICE Local Persons</strong></em></span></th>
                          <th bgcolor=#76b2f0><span style="font-weight: 400">
                            <em style="font-style: normal"><strong> Home Pht</strong></em></span></th>


 </tr>

  <%
Dim fielddata2
dim v2
v2 = 1

do while rs2.eof=false
if v2 mod 2 = 0 then
   Response.Write("<tr bgcolor=#e3effe>")
else
   Response.Write("<tr bgcolor=f8f8ff>")

end if


Response.Write("<td><input type=checkbox name=delrec value='" & rs("date_joined") & "' ></td>")

Response.Write("<td align=center>")
Response.Write("<a target=_self title='Select Emp_ID' href='update_emp.asp?empno=" & (rs("date_joined")) & "'>" & rs("date_joined") & "</a>")
Response.Write("</td>")

Response.Write("<td align=left>" & rs("MOBILE") & "</td>")
Response.Write("<td align=left>" & rs("LOCAL_PHONE") & "</td>")
Response.Write("<td align=left>" & rs("ICE_LOCAL_PERSON") & "</td>")
Response.Write("<td align=left>" & rs("HOME_PHONE") & "</td>")



v2 = v2 + 1

rs2.movenext
loop

end if // line 178


%>
</table>
<input type=submit name=submit id=submit value=NextCol>


it give error in line 178,
Error Type:
Microsoft VBScript compilation (0x800A03FB)
Expected 'Loop'
/dcil/test/morecolum.asp, line 178

I give loop then it give error that expected statement
it is give error in loop,
please check the loop

thanks and regards
Mateen





 
Old July 25th, 2007, 09:49 PM
Authorized User
 
Join Date: Jun 2007
Location: Las Vegas, Nevada, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well if you are geting an expected loop error and you have the loop in your code the odds are you missed something above to like a closing " or somehting so the code is not reading the loop command.. with all the response.write's i see in your code it is very possable...


I would look thru and make sure every open " has a close ect. You can remove some of the headach by not using response.write for all your HTML it can get messy
You can just put a close asp tag and write the html then open the asp back up. I normaly do this type of thing like this


<Table>
<%
IF var=value then %>
<tr><TD>Stuff here</td></tr>
<%end if%>

This way you are taking out some of added quotes ect and this can make tracking down a bug a little simpler

Jim

 
Old July 25th, 2007, 10:00 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Expected loop means just that. You are missing a closing 'Loop'

Do a search of your code for 'Do While' you will find two. Now do a serch for 'Loop' you will only find one - Thats you problem. After a quick look I believe you have failed to close the following loop:

do while rs.eof=false

Wind is your friend
Matt
 
Old July 28th, 2007, 07:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.

now I use only two column, onclick it should display more column information, but now there is no error messge, same page reopen,
it should be showing another two column informations how ?


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<script language="VBSCRIPT">
Sub button_OnCLick
form1.hiddenbox.value="1"
form1.submit
End Sub
</Script>

<form method=post action="http://dcilweb/dcil/test/tablecol.asp" id=FORM1 name=FORM1>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=1 bordercolor="skyblue" style="border-collapse:collapse; mso-table-layout-alt:fixed;border:none;mso-border-alt:solid windowtext 1.5pt; mso-padding-alt:0in 5.4pt 0in 5.4pt">
  <tr bgcolor=#76b2f0>
<th bgcolor=#76b2f0><span style="font-weight: 400">
  <em style="font-style: normal"><strong> Emp No</strong></em></span></th>
<th bgcolor=#76b2f0><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      Name</strong></em></span></th>
 </tr>

  <%

set cn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
cn.ConnectionString=".... "
cn.Open

pn=Request.QueryString("pn")

rs.Open "SELECT REC_ID, EMP_ID,NAME,POSITION_CODE,DEPARTMENT_CODE,DATE_JOI NED,MOBILE,LOCAL_PHONE,ICE_LOCAL_PERSON,HOME_PHONE FROM EMPLOYEE ORDER BY NAME",cn,3,1

Dim fielddata
dim v
v = 1

do while rs.eof=false
if v mod 2 = 0 then
   Response.Write("<tr bgcolor=#e3effe>")
else
   Response.Write("<tr bgcolor=f8f8ff>")

end if

Response.Write("<td align=left size=3>" & rs("EMP_ID") & "</td>")
Response.Write("<td align=left>" & rs("Name") & "</td>")

v = v + 1

rs.movenext
loop


IF Request.form("Hiddenbox") = "1" Then
%>

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=1 bordercolor="skyblue" style="border-collapse:collapse; mso-table-layout-alt:fixed;border:none;mso-border-alt:solid windowtext 1.5pt; mso-padding-alt:0in 5.4pt 0in 5.4pt">
  <tr bgcolor=#76b2f0>
<th bgcolor=#76b2f0><span style="font-weight: 400">
  <em style="font-style: normal"><strong>position</strong></em></span></th>
<th bgcolor=#76b2f0><span style="font-weight: 400">
    <em style="font-style: normal"><strong>
      department</strong></em></span></th>

 </tr>

 <%
Dim fielddata2
dim v2
v2 = 1

do while rs.eof=false
if v2 mod 2 = 0 then
   Response.Write("<tr bgcolor=#e3effe>")
else
   Response.Write("<tr bgcolor=f8f8ff>")

end if

Response.Write("<td align=left>" & rs("POSITION_CODE") & "</td>")
Response.Write("<td align=left>" & rs("DEPARTMENT_CODE") & "</td>")

v2 = v2 + 1

rs2.movenext
loop
end if

%>

</table></p>
<input type=submit value=morecolum id=button_OnCLick name=button_OnCLick>
</BODY>
</HTML>

Please help
regards
Mateen






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Distinct two colums but select other colums ALPEN07 SQL Server 2005 2 April 5th, 2008 06:08 AM
Displaying items in Colums in roes azambee Access 4 January 5th, 2007 04:57 AM
Dynamically adding Colums to datagrid ? vivekshah C# 0 April 15th, 2006 02:54 AM
group extra colums jun99 PHP How-To 0 December 5th, 2005 02:43 PM
Sorting on mulitple colums Greg Griffiths Javascript 0 June 20th, 2003 12:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.