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

Making a neat phone list 1

Status
Not open for further replies.

JLSigman

Programmer
Joined
Sep 20, 2001
Messages
261
Location
US
Hi,

In my never-ending work on the personnel directory, I've finally gotten to the phone list. The repeat region part is the simple part... what I'd like to be able to do is format the region so it'll fit on one page, in two or more columns. Can someone point me in the right direction, please? Thanks,

Jennifer Sigman
 
HI Jennifer,

Have you worked out how many columns of your repeat field can fit the length of the page? If you have then you could fit them in twice or more in new columns. That's the easy bit, not you've got to find out how the heck to wrap the code around each of your repeating field columns. What's the need for having it all on one page? If you provide a small and perfectly formed search element to the top of your page you could have the top 5 in the lower area of the same page, thus alleviating the need to concern yourself with some fairly hairy code.
However, if you're sure that's what you need, I haven't a clue, this is a Derren, Link9 or cheech special (not forgetting schase! ;))

Sorry to be a little vague, let me know if you can get it to work, there's gotta be some code out there, I may just look and get back to you


M
 
How do I fit the regions into columns? That's what I don't know.

The need for having it all on one page is so it prints out on one page. Pain in the butt, I know, but that's what the boss wants. ;-)

Thanks,

Jennifer Sigman
 
too bad you can't do Lawson's A B C D E F G (hey at least he knows the alphabet) search - it works pretty slick.

the only thing I can think of here - and I bet Derren or Lawson can help. Is the repeat by column, then row.

Kind of like a picture gallery
 
Repeat by column, then row... I'll see if I can figure out how to do that, thanks.

Jennifer Sigman
 
heres a thread on 3 per row for an image gallery - maybe you can fiddle with it

thread333-187718
 
Oops! Here is a spot of code that I use for creating a two column repeating region (something I rustled up earlier!) I have stripped a lot of chaff out of it, but the principle should be there - recordset is called rsCategories

Code:
<%
col=1
While NOT rsCategories.EOF 
   If col=1 then ' Start of a new row - write row code %>
      <tr valign=&quot;top&quot;>
<% End if 
   ' write out your cell %>
	<td>Your fields etc...</td>
<% If col=2 then ' End of a row - finish row code %>
      </tr>
<% End if
   ' Column over, increment col variable
   col = col + 1
   If col=3 then col=1
   rsCategories.movenext()
   If rsCategories.EOF and col=2 then 
   ' this is a nice bit - if we end on the first cell
   ' of a row, we add a blank cell, to keep our table
   ' nice and evenly balanced %>
      <td> </td>
<% End if
Wend
%>

Breakdown - analyzing the table we need to know when to start and finish a row. In our case, a two column table, the first cell we draw needs to start a row, but the row is ended after the second cell. Once we have drawn that second cell we can start counting again from one.

That is the purpose for the &quot;col&quot; variable, so we can keep track of where we are. We increment it after each cell we draw.

Code:
col value                         add one to col
  (1)     start row - draw cell   becomes 2
  (2)     draw cell - end row.    becomes 3 - reset to 1

And so on and so on. If you want to do this for 3 or more columns just change the reset value of &quot;col&quot; and the test value for the end of row.

Code:
If col=
[number of columns + 1]
Code:
 then col=1

and

Code:
<% If col=
[number of columns]
Code:
 then ' End of a row - finish row code %>

I hope that this helps and I have stayed lucid throughout!
Derren
[Mediocre talent - spread really thin]
 
He's done it again. You da man Derren!

M

P.S. Had enough of Word then?
 
I changed my signature because I kept getting battered by the top experts in the &quot;Microsoft Office&quot; forum! Miserable buggers. Derren
[Mediocre talent - spread really thin]
 
derren,

Next dumb question of the day. Where does this code go? Thanks,

Jennifer Sigman
ASP class is at the end of April... boss wants this yesterday. ;-)
 
wow your boss is more forgiving than mine.............
 
Not so easy life for me!

Jennifer - I thought you said the easy part was the repeat region? [wink]

Look, create yourself a nice table with as many columns in it as you like, with the formatting you require, and with some dummy text in. Keep messing with it until it becomes your ideal neat (meaning tidy) table of phone numbers (or whatever). Decide on the number of columns you are going to want, whether you are going to use a header row, blah, blah, blah.

Once you are happy with this look at the table and decide which row (not column) is going to be your repeating area. That is where your code is going. Once you have done this put the fields that you are actually going to use in one of the cells and post the code you have written for the whole table. It will make more sense when I can talk in the terms that you are using.

[fish] Derren
[Mediocre talent - spread really thin]
 
OK, here's the code:
<table width=&quot;42%&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot;>
<tr>
<td width=&quot;60%&quot;><b>NAME</b></td>
<td width=&quot;40%&quot;><b>PHONE</b></td>
</tr>
<%
col=1
While NOT rsPhone.EOF
If col=1 then
<tr valign=&quot;top&quot;>
<% End if %>
<td width=&quot;60%&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;-2&quot;><%=(rsPhone.Fields.Item(&quot;LAST_NAME&quot;).Value)%>, <%=(rsPhone.Fields.Item(&quot;FIRST_NAME&quot;).Value)%></font></td>
<% If col=2 then %>
<td width=&quot;40%&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;-2&quot;><%=(rsPhone.Fields.Item(&quot;PHONE&quot;).Value)%></font></td></tr>
<% End if
col = col +1
If col = 3 then col =1
rsPhone.movenext()
<%End if
WEnd
%>
<tr>
<td width=&quot;60%&quot;> </td>
<td width=&quot;40%&quot;> </td>
</tr>
<tr>
<td width=&quot;60%&quot;> </td>
<td width=&quot;40%&quot;> </td>
</tr>
</table>

When I try to run this, I get this error:
Microsoft JScript compilation error '800a03ec'

Expected ';'

/baq/directory/TMP3i9qptmwz9.asp, line 26

While NOT rsPhone.EOF
------^

Thanks a ton,

-jenn
 
Hi Jenn

You have got your code endings all muddled.

Code:
<table width=&quot;42%&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot;>
  <tr> 
    <td width=&quot;60%&quot;><b>NAME</b></td>
    <td width=&quot;40%&quot;><b>PHONE</b></td>
    <td width=&quot;60%&quot;><b>NAME</b></td>
    <td width=&quot;40%&quot;><b>PHONE</b></td>
  </tr>
  <%
  col=1
  While NOT rsPhone.EOF
      If col=1 then
%>
Code:
        <tr valign=&quot;top&quot;> 
    <% End if %>
    <td width=&quot;60%&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;-2&quot;><%=(rsPhone.Fields.Item(&quot;LAST_NAME&quot;).Value)%>, <%=(rsPhone.Fields.Item(&quot;FIRST_NAME&quot;).Value)%></font></td>
    <td width=&quot;40%&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;-2&quot;><%=(rsPhone.Fields.Item(&quot;PHONE&quot;).Value)%></font></td>
  <% If col=2 then %>  
   </tr>
       <% End if
    col = col +1
    If col = 3 then col =1
       rsPhone.movenext()
    End if
Wend
    %>
</table>

I also took the liberty of making it so that your phonelist has two columns of people. At the moment you are just repeating one row.

Paste that in and see Derren
[Mediocre talent - spread really thin]
 
Hmmm... cut and pasted that in, I'm still getting the

Microsoft JScript compilation error '800a03ec'

Expected ';'

/baq/directory/TMP4fjjltmy6d.asp, line 28

While NOT rsPhone.EOF
------^

error. Is this written in JavaScript or VBasic?

Jennifer Sigman
Code-borrower extraordinaire
&quot;They call us public servants for a reason...&quot;
 
This is in vbscript in an asp page.

There is a possibility that the unfinished code could be above line 28, because there are no errors in that bit of code to create that. Give us the top bit as well. Derren
[Mediocre talent - spread really thin]
 
Here's the rest of the code... the table code goes directly under this.

<%@LANGUAGE=&quot;JAVASCRIPT&quot;%>
<!--#include file=&quot;Connections/connDirectory.asp&quot; -->
<%
var rsPhone = Server.CreateObject(&quot;ADODB.Recordset&quot;);
rsPhone.ActiveConnection = MM_connDirectory_STRING;
rsPhone.Source = &quot;SELECT LAST_NAME, FIRST_NAME, PHONE FROM DIRECTORY WHERE ROOM_NUM <> 'Dist' ORDER BY USERID ASC&quot;;
rsPhone.CursorType = 0;
rsPhone.CursorLocation = 2;
rsPhone.LockType = 3;
rsPhone.Open();
var rsPhone_numRows = 0;
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;> Jennifer Sigman
Code-borrower extraordinaire
&quot;They call us public servants for a reason...&quot;
 
Your language should be &quot;VBSCRIPT&quot; not &quot;JAVASCRIPT&quot; !!!

And drop all those unsightly semi-colons from the end of each of your asp lines - they aren't needed and can cause problems. Derren
[Mediocre talent - spread really thin]
 
I just spotted somthing else!

The last couple of lines (ish) of the repeat code should read

Code:
    If col = 3 then
       col =1
    End if
    rsPhone.movenext()
Wend

[You had added an extra &quot;end if&quot; to my line &quot;if col=3 then col=1&quot;]

Derren
[Mediocre talent - spread really thin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top