Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-21-2009, 01:08 PM   PM User | #1
thisanthrope
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thisanthrope is an unknown quantity at this point
change font size of #s in address

I operate as a admin a online print site where clients can enter in contact info to create imprint on promotional items.

I create pdf templates with field placeholders |1.1|[address]

This template is uploaded to the print site which interprets the tags and makes them into variable fields for clients to enter in their info. The site can pull the font name, size, position, etc... from the pdf template.

For each info field that the site creates it also has an option to apply javascript to that field. So if the template predefines font size X, I just want to apply code that will affect only the numbers of that text and make the numbers a larger font size than the letters.

The code I'm use to writing is pretty simple stuff for example to format dots instead of dashes for phone numbers like:
Code:
if (hasValue(curInput.name))
{
if (! AutoFormat(curInput, '###.###.####', 'Please enter your number in a 555.555.5555 format'))curInput.focus();
}
I've got no clue where to begin to do what I'm asking so a little help would be much appreciated.

thanks,
thisanthrope is offline   Reply With Quote
Old 05-21-2009, 06:31 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by thisanthrope View Post
So if the template predefines font size X, I just want to apply code that will affect only the numbers of that text and make the numbers a larger font size than the letters.
AFAIK that is not possible.
Philip M is offline   Reply With Quote
Old 05-22-2009, 12:56 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,175
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
It would be easy to *replace* each digit found with the same digit in a different font.

Is that what you are after???

Example:
Code:
<style>
span.BIGRED { font-size: large; color: red; }
</style>
<script>
var demo = "My phone number is 800-111-1212 and I am 37 years old."

var reBig = /(\d+)/g
demo = demo.replace( reBig, "<span class=BIGRED>$1</span>");
document.write( demo );
</script>
Old Pedant is online now   Reply With Quote
Old 05-22-2009, 02:13 PM   PM User | #4
thisanthrope
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thisanthrope is an unknown quantity at this point
Quote:
Originally Posted by Old Pedant View Post
It would be easy to *replace* each digit found with the same digit in a different font.

Is that what you are after???

Example:
Code:
<style>
span.BIGRED { font-size: large; color: red; }
</style>
<script>
var demo = "My phone number is 800-111-1212 and I am 37 years old."

var reBig = /(\d+)/g
demo = demo.replace( reBig, "<span class=BIGRED>$1</span>");
document.write( demo );
</script>
well, not sure but I'll play around with this.

the reason I was needing this was that a certain customer uses a specific font. That font's numbers are slightly larger than the letters so when manually typesetting their business collateral, the street address letters are 6pt and the numbers 4.75pt so that they all appear at the same size. PITA

I've actually already resolved this by just making a custom font by editing the original so all characters are the same size.

It would have been nice to just plug in some javascript to automate this but problem fixed. Thanks for the help though and I'm sure this bit of code will be useful in other areas!
thisanthrope is offline   Reply With Quote
Old 05-22-2009, 02:20 PM   PM User | #5
thisanthrope
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thisanthrope is an unknown quantity at this point
Code:
<style>
span.BIGRED { font-size: large; color: red; }
</style>
<script>
var demo = "My phone number is 800-111-1212 and I am 37 years old."

var reBig = /(\d+)/g
demo = demo.replace( reBig, "<span class=BIGRED>$1</span>");
document.write( demo );
</script>
Hey, this actually does work! not sure yet if I can specify a font point size instead of large, small, etc.... but yeah, this works.
thisanthrope is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:29 PM.


Advertisement
Log in to turn off these ads.