Forum Moderators: open

Message Too Old, No Replies

rewrite telephone numbers

asp vb

         

macrobe

2:24 pm on May 15, 2007 (gmt 0)

10+ Year Member



i use an oldschool access - asp site, containing the format "tel: 0055 555 555 555" in various fields.

i am now looking in to setting up a 4 page dynamic website using the same content special for mobile users, stripping all images and bandwith consuming design elements.

But i ran into an massive job converting the telephone numbers into dialable numbers.

is there any way to impement a function or a re-write to go form:
"tel: 0055 555 555 555"
to
"<a href="wtai://wp/mc;0055555555555">tel: 0055 555 555 555</a>

maybe a vb fuction to "find and replace" a string to the specified format?

i would appreciate any referral to contents that are helpfull.

celgins

3:48 pm on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can't you use the VB Replace function to accomplish this?

For example:

<%
Dim phonenum
phonenum="tel: 0055 555 555 555"

newphonenum=Replace(phonenum," ","",6)

Response.Write "<a href='wtai://wp/mc;"&newphonenum&"'>phonenum</a>"
%>

You're basically taking the string "tel: 0055 555 555 555" and replacing each space with a no-space. The number 6 is used to strip out the "tel: ".

I tested it and it works.

macrobe

8:34 am on May 16, 2007 (gmt 0)

10+ Year Member



that works ok if you have a fixed field for the telephone number, in my case i want to filter out the telephone numbers out of the text in any fields.

i used javacript to do something like this:

<%
var str = (Recordset.Fields.Item("AnyTypeOfField").Value);
var telnr = 5 + (str.indexOf("Tel:"));
var telwithspace = (str.substring(telnr,telnr+13));
var telnospace = (telwsp.replace(/ /gi, ""));
Response.write("<a href='wtai://wp/mc;+34" + telnsp + "'target='blank'>Tel:" + telwsp + "</a>");
%>

it works to the same principe - searches for "Tel:" cuts the number behind it strips the spaces and writes the link i want.