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!

output display to multiple div or span based on sql content

Status
Not open for further replies.

dal2

Technical User
May 16, 2005
34
US
Does anyone know the best way to output overflow data into a new div table based on sql output?

Say the display is for a 3 x 5 card and you want the extra data to add a new card and populate it.

tia,
David
 
Loop through the recordset and use a counter to check if the maximum allowed on a card has been reached, when it has, create a new div/card etc...

Code:
dim i : i = 0
while not oRS.EOF
  i = i+1
  if i mod 3 = 0 then
    if i <> 0 then response.write("</div>") end if
    response.write("<div>")
  end if
  response.write(oRS.Fields("some_field"))
  oRS.MoveNext
wend
if i > 0 then response.write("</div>") end if

or something along those lines.. the above is freehand with no testing so watch out for typo's etc.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
I might be missing something in what you are asking so ignore me if I am but...

If you are outputing textual information onto the screen you are going to run into issues determining how much data is going to be required for each 3x5 card because you cannot easily predict how much space the text is going to take. It all varies based not only on the font settings but also on the font that resides on the individuals PC that might output the data. A font of the same name may vary in characteristics from one machine to the next.
You will have to be very selective of which font will be used and enforced on the page for the output in order to keep the output consistent.

This may not be a major issue based on your application. If it becomes one then perhaps you can use tricks. It may be possible for instance to limit the total number of characters to write to the div but leave the settings for the div to allow it to stretch vertically. Once the div is rendered you can test it's height to see if perhaps it stretched and if so go back and repopulate it with a bit less information until it fits.

Come to think of it, this could be an interesting method to use as a discovery routine to determine how much data will fit using any specific font on the fly so you can be more flexible with the font size and type without worrying that the output will be overflow it's boundaries or get cut off.



It's hard to think outside the box when I'm trapped in a cubicle.
In an increasingly self-focused society it is important to recognize the unselfish actions of others so they will feel encouraged to continue such actions. Please give acknowledgement to those who aid you whether it is waving to the person who let you out in traffic, tha
 
Actually, you could use a little CSS trickery to assist with this. I'm thinking you could use a fixed width font and set the size of the div using inches as the unit of measure. At this point it should be possible to determine how many characters that font will fit on a single line. Additionally you can define the height of a line of text so it matches up with however many lines are usually on a 3x5 card. This will limit how much the end user wants to mess with the font-size and will also look pretty cool if you use a repeated background on the divs to create the blue lines.
Once you know how many characters a line can hold you should be able to determine how many lines a given output will take. When you have filled the available number of lines than you know to finish the current card and start a new one.

Hmm, think I am going to play with this idea. It could be easily re-used for outputting a sheet of lined paper, etc.

-T

barcode_1.gif
 

Good points guys - I just went with the first sentence and brushed the second one off as an example. But if it is for actual 3x5 cards you're absolutely right, it will require some careful considerations of font sizing and character outputs as well as lines.

It depends on the field content sizes for a specific card - e.g. what is the maximum space required and how will the output be formatted - e.g. 3 fields on spearate lines would mean there was less overall space than 1 field. Also, would field names be required, and how about borders and spacing ?

Lots to think about if it is actually for a 3x5 card.



A smile is worth a thousand kind words. So smile, it's easy! :)
 
This is what I was thinking of:
Things I learned:
1) Don't use an image for the background, they don't scale with browser resolution. Instead I'm outputting each line in a paragraph tag and adding the underline with CSS
2) It may be better to break it down into words first and then only split up words if they are longer than a certain width. As you could see from my example it looks kind of silly if you put a whole lot of content on a card and it starts breaking it wherever it wants.

And then a random thought. I don't know how well these would work for printing. You might have to get rid of the margins and just use CSS to apply page breaks. Dunno, I'm going to play more with the word breaks, i'm not too concerned about printing.

-T

barcode_1.gif
 
Thank you all for your efforts on this question. Tarwyn, I would like to see how you solved it. Unfortunately, the client dropped me from the project. Apparently, I didn't figure it out fast enough...well, I tried. I could output to the cards using a mid and len but the count was off slightly and it didn't display as nice as yours.

Thanks anyway, I really appreciate your efforts.
David
 
You would also have to determine if the output is going to wrap at xx characters or if it would wrap at the next to last word that fit on the line. I am not running under the assumption that the line length is set for a specific size card/page. Then you have to account for linefeed and carriage return characters and either ignore them or accomodate them by dropping to the next line.

It sounds like a simple project at the start but can get pretty complicated depending on your requirements for the output.
I did something similar to output text into a textarea field and still maintain original formatting. I just did not have to worry about the height of the output which made it a bit simpler.


It's hard to think outside the box when I'm trapped in a cubicle.
In an increasingly self-focused society it is important to recognize the unselfish actions of others so they will feel encouraged to continue such actions. Please give acknowledgement to those who aid you whether it is waving to the person who let you out in traffic, tha
 
I was looking into getrows() with a crlf. Would this be a useful solution? Again, accounting for pageview / character - row requirements. What about an XML conversion with an XSLT output?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top