E-mail Address Makes Table Field Too Wide

Results 1 to 2 of 2

Thread: E-mail Address Makes Table Field Too Wide

  1. #1
    J. Paul Schmidt Guest

    Default E-mail Address Makes Table Field Too Wide

    I&#039;ve got a table showing customers. The company name field (drawn from a database) might come out something like this:<BR>&lt;td width="100"&#062;<BR> My Very Very Very Long Company Name<BR>&lt;/td&#062;<BR><BR>It works alright as a very long company name above would be shown over SEVERAL VERTICAL LINES and STILL KEEP THE HORIZONTAL WIDTH of the table column at 100 pixels. This is because the words in the company name DO HAVE SPACES and NO ONE WORD is longer than 100 pixels.<BR><BR>But the problem is with the following e-mail field which has no spaces:<BR>&lt;td width="100"&#062;<BR> MyVeryVeryLongEmailAddress@MyHost.com<BR>&lt;/td&#062;<BR><BR>This does NOT get shown over several vertical lines because there are no spaces or dashes in it. Instead it actually forces the table column to be much wider than 100 pixels.<BR><BR>So how can I get the e-mail field which has no spaces in it to be shown over several vertical lines and NOT force the table column to be any wider?<BR><BR>And by the way I was NOT able to do the same thing with a div using style either. I&#039;d just love to have something that would work for this (in a table or div or whatever)! It would be especially useful for when a user wants to print out a page and only so many columns fit on a page...<BR><BR>Thanks a lot,<BR>-Paul<BR><BR>J. Paul Schmidt, MBA<BR>Databases on the Web<BR>http://www.Bullschmidt.com

  2. #2
    Join Date
    Dec 1969

    Default RE: E-mail Address Makes Table Field Too Wide

    Well, I would imagine it could be done server-side. This might be ungainly, but...<BR><BR>Read the email string in, determine it&#039;s length. At default text size on my machine(and the users will all vary) I can fit about 10 to 16 characters in a 100 pixel wide cell, depending on the character(i or W, for instance). <BR><BR>Once length is determined, if it&#039;s less than 16(doubtful for an email address, right?) nothing needs to be done.<BR><BR>More probably, we need to start inserting some break tags in the string before we display it. How do we do that? Well, I don&#039;t know yet. Let&#039;s figure it out. There are probably a million better ways to do this(regular expressions, client-side javascript, getting someone smarter than me to do it...) but this is what I can figure...<BR><BR>&#060;%<BR>s = "MyVeryVeryLongEmailAddress@MyVeryLongInternetDoma inNameblahblahblah.com"<BR>mailtoStr = s<BR>strLen = Len(s)<BR>doLen = strLen<BR>&#039;Setting brTag to nothing for first time through, then it will insert the "&lt;br&gt;" tag<BR>brTag = ""<BR><BR>&#039;loop our way through the string, 12 chars at a time<BR>Do Until doLen &#060; 12<BR> &#039;Rip the first 12 characters off the string<BR> tempStr = Left(s, 12)<BR> "Start constructing the string<BR> newStr = newStr & brTag & tempStr<BR> doLen = (doLen - 12)<BR> s = Right(s, doLen)<BR> &#039;Now set the break tag so it will be there for the rest of the string<BR> brTag = "&lt;br&gt;"<BR>Loop<BR><BR>&#039;Now to make sure that we don&#039;t append too many characters at the end, we may need to add another break tag<BR>If doLen &#060; 12 Then<BR>newStr = newStr & "&lt;br&gt;" & s<BR>Else<BR>newStr = newStr & s<BR>End If<BR>%&#062;<BR>&#060;html&#062;&#060;body&#062;< BR>&#060;table border=1&#062;<BR>&#060;tr&#062;&#060;td width=100&#062;&#060;a href="mailto:&#060;%=mailtoStr%&#062;"&#062;&#060; %=newStr%&#062;&#060;/a&#062;<BR>&#060;/td&#062;&#060;/tr&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR><BR><BR>This works, at least the few times I did it with some different length strings. If there are bugs, let me know through the board here. It&#039;s just a "quick and dirty" version that I banged together just now.<BR><BR>On the flip, if it works, lemme know that too.<BR><BR>I apologize for the horrible lack of commenting in my code...<BR><BR>Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts