Adding removing spaces in phone numbers db/web

M

mettá

I have phone numbers stored in a db as xxxxx xxxxxx however I am starting to
set up a mobile/pda site and the numbers need to disply as xxxxxxxxxxx (no
spaces) for the call link to work

I can edit the db to remove the spaces BUT would like then to display on the
main web site with a space. Anyone know a simple solution???

Thanks
M
 
E

Evertjan.

mettá wrote on 23 aug 2009 in microsoft.public.inetserver.asp.general:
I have phone numbers stored in a db as xxxxx xxxxxx however I am
starting to set up a mobile/pda site and the numbers need to disply as
xxxxxxxxxxx (no spaces) for the call link to work


Are you sure this is not a school assignment?

<% 'vbs
tel = "12345 678901"
response.write onlyNumbers(tel)
%>

<script type='text/javascript' runar='server'>
function onlyNumbers(x) {
return x.replace(/\D+/g,'');
};
I can edit the db to remove the spaces BUT would like then to display
on the main web site with a space. Anyone know a simple solution???

How would you know where the spaces used to be?
Or is there a rule for your country?
 
M

mettá

Hi, thanks for your response but I cannot get this working, I have also
tried;

<%
phonNum=FP_FieldVal(fp_rs,"tel")
replace phonNum," ",""
response.write phonNum
%>

But it fails to remove any spaces!

I also tried
<%
tel2 = FP_FieldVal(fp_rs,"tel")
response.write onlyNumbers(tel2)
%>

I then get the error;
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'onlyNumbers'


What am I doing wrong here??
Thanks
M
 
M

mettá

Sorted it now with the help of SRB
The following is the answer!

<%
phonNum=FP_FieldVal(fp_rs,"tel")
If len(phonNum)>0 then
phonNum=replace(phonNum," ","")
Else
phonNum="None"
End If%>
response.write(phonNum)
%>

Thanks for trying!
M
 
E

Evertjan.

mettá wrote on 29 aug 2009 in microsoft.public.inetserver.asp.general:

[Please do not toppost on usenet]
Sorted it now with the help of SRB
The following is the answer!

Perhaps "a", but do not flater yourself bij knowing "the".

<%
phonNum=FP_FieldVal(fp_rs,"tel")
If len(phonNum)>0 then
phonNum=replace(phonNum," ","")

I would remove all the spaces first.
Then an entry like
phonNum = " "
would also work,
and the code is more compact.

=====================================
<%
phonNum = FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
If len(phonNum)=0 then
phonNum="None"
End If
response.write phonNum
%>
=====================================
Else
phonNum="None">
End If> %>
response.write(phonNum)
%>

This will never work, two %> in succession

Next time copy paste your working code and do not retype, I suggest.


You seem to have a problem with the () logic of VBS.
response.write(phonNum)

response.write phonNum

Statements do not need () around the parameters,
and if there are more than one paramater they cannot have them,
so better NEVER use () as statement parameter delimiters.

A function on the other hand needs them.

phonNum = replace(phonNum," ","")

This is just nonsense, because also you did not use the result.
%>

Thanks for trying!

Trying what?
 
M

mettá

Hi Evertjan

Well now, the answer I posted was AN answer, it worked, the (<%) was
missing at the start of response.write I posted in my reply! sorry about
that. I'm not flattering myself I was if anything flattering SRB, I was also
thanking you for trying to help, sadly what you offered did not work for me.
The actual code (true copy) that works (for me) is;

<%
phonNum=FP_FieldVal(fp_rs,"tel")
If len(phonNum)>0 then
phonNum=replace(phonNum," ","")
Else
phonNum="None"
End If
%>
....
<p>Tel:<a href="tel:<%=(phonNum)%>"><%=FP_FieldVal(fp_rs,"Tel")%></a></p>

This produces
Tel:12345 678 901
and the link: tel:12345678901


If you can see anything wrong or excessive about this please let me know.
M





Evertjan. said:
mettá wrote on 29 aug 2009 in microsoft.public.inetserver.asp.general:

[Please do not toppost on usenet]
Sorted it now with the help of SRB
The following is the answer!

Perhaps "a", but do not flater yourself bij knowing "the".

<%
phonNum=FP_FieldVal(fp_rs,"tel")
If len(phonNum)>0 then
phonNum=replace(phonNum," ","")

I would remove all the spaces first.
Then an entry like
phonNum = " "
would also work,
and the code is more compact.

=====================================
<%
phonNum = FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
If len(phonNum)=0 then
phonNum="None"
End If
response.write phonNum
%>
=====================================
Else
phonNum="None">
End If> %>
response.write(phonNum)
%>

This will never work, two %> in succession

Next time copy paste your working code and do not retype, I suggest.


You seem to have a problem with the () logic of VBS.
response.write(phonNum)

response.write phonNum

Statements do not need () around the parameters,
and if there are more than one paramater they cannot have them,
so better NEVER use () as statement parameter delimiters.

A function on the other hand needs them.

phonNum = replace(phonNum," ","")

This is just nonsense, because also you did not use the result.
%>

Thanks for trying!

Trying what?
 
E

Evertjan.

mettá wrote on 29 aug 2009 in microsoft.public.inetserver.asp.general:
Hi Evertjan

Well now, the answer I posted was AN answer, it worked, the (<%) was
missing at the start of response.write I posted in my reply! sorry
about that. I'm not flattering myself I was if anything flattering
SRB, I was also thanking you for trying to help, sadly what you
offered did not work for me. The actual code (true copy) that works
(for me) is;

<%
phonNum=FP_FieldVal(fp_rs,"tel")
If len(phonNum)>0 then
phonNum=replace(phonNum," ","")
Else
phonNum="None"
End If
%>
...
<p>Tel:<a
href="tel:<%=(phonNum)%>"><%=FP_FieldVal(fp_rs,"Tel")%></a></p>

This produces
Tel:12345 678 901
and the link: tel:12345678901


If you can see anything wrong or excessive about this please let me
know. M


Seems you did not read my answer at all!

1
You persist in topposting.

2
You do not note the improvement I suggested.

3
You make the mistake by sometimes letting "tel:None" be entered in the href
link, while you put an empty string in the clickable link text.

4
There is no reason to put () here:
href="tel:<%=(phonNum)%>">

5
"tel: in the link text will probably get you nowhere, since the usual link
form [skype, mobile phones] is "callto:"

try [you, not me]:

<p>
Phone: <a href='callto:<% = phonNum %>'><%=phonNum%></a>
</p>

6
and please, do not quote signatures in your responses.

Evertjan. said:
mettá wrote on 29 aug 2009 in
microsoft.public.inetserver.asp.general:

[Please do not toppost on usenet]
Sorted it now with the help of SRB
The following is the answer!

Perhaps "a", but do not flater yourself bij knowing "the".

<%
phonNum=FP_FieldVal(fp_rs,"tel")
If len(phonNum)>0 then
phonNum=replace(phonNum," ","")

I would remove all the spaces first.
Then an entry like
phonNum = " "
would also work,
and the code is more compact.

=====================================
<%
phonNum = FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
If len(phonNum)=0 then
phonNum="None"
End If
response.write phonNum
%>
=====================================
Else
phonNum="None">
End If> %>
response.write(phonNum)
%>

This will never work, two %> in succession

Next time copy paste your working code and do not retype, I suggest.


You seem to have a problem with the () logic of VBS.
response.write(phonNum)

response.write phonNum

Statements do not need () around the parameters,
and if there are more than one paramater they cannot have them,
so better NEVER use () as statement parameter delimiters.

A function on the other hand needs them.

phonNum = replace(phonNum," ","")
replace phonNum," ",""

This is just nonsense, because also you did not use the result.
%>

Thanks for trying!

Trying what?
 
M

mettá

Hi

My way is to top post, however...


Evertjan. said:
mettá wrote on 29 aug 2009 in microsoft.public.inetserver.asp.general:



Seems you did not read my answer at all!

1
You persist in topposting.

I hear you.
2
You do not note the improvement I suggested.

That is because I could not clearly understand what you were saying, however
<%
phonNum=FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
response.write phonNum
%>

works too!
3
You make the mistake by sometimes letting "tel:None" be entered in the
href
link, while you put an empty string in the clickable link text.

I agree EXCEPT there is other code that knows if a tel field is empty or
less than x characters.
4
There is no reason to put () here:

Hmm, this depends on which method I use, if the working example I gave in my
previous response is used the () is required!
5
"tel: in the link text will probably get you nowhere, since the usual link
form [skype, mobile phones] is "callto:"

try [you, not me]:

<p>
Phone: <a href='callto:<% = phonNum %>'><%=phonNum%></a>
</p>

On the two web enabled phones I have they work with "tell:", "callto:" is
for Skype
6
and please, do not quote signatures in your responses.
What?

Thanks
M
Evertjan. said:
mettá wrote on 29 aug 2009 in
microsoft.public.inetserver.asp.general:

[Please do not toppost on usenet]

Sorted it now with the help of SRB
The following is the answer!

Perhaps "a", but do not flater yourself bij knowing "the".


<%
phonNum=FP_FieldVal(fp_rs,"tel")

If len(phonNum)>0 then
phonNum=replace(phonNum," ","")

I would remove all the spaces first.
Then an entry like
phonNum = " "
would also work,
and the code is more compact.

=====================================
<%
phonNum = FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
If len(phonNum)=0 then
phonNum="None"
End If
response.write phonNum
%>
=====================================

Else
phonNum="None">
End If> %>
response.write(phonNum)
%>

This will never work, two %> in succession

Next time copy paste your working code and do not retype, I suggest.


You seem to have a problem with the () logic of VBS.

response.write(phonNum)

response.write phonNum

Statements do not need () around the parameters,
and if there are more than one paramater they cannot have them,
so better NEVER use () as statement parameter delimiters.

A function on the other hand needs them.

phonNum = replace(phonNum," ","")

replace phonNum," ",""

This is just nonsense, because also you did not use the result.

%>

Thanks for trying!

Trying what?
 
M

mettá

Hi

My way is to top post, however...


Evertjan. said:
mettá wrote on 29 aug 2009 in microsoft.public.inetserver.asp.general:



Seems you did not read my answer at all!

1
You persist in topposting.

I hear you.
2
You do not note the improvement I suggested.

That is because I could not clearly understand what you were saying, however
<%
phonNum=FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
response.write phonNum
%>

works too!
3
You make the mistake by sometimes letting "tel:None" be entered in the
href
link, while you put an empty string in the clickable link text.

I agree EXCEPT there is other code that knows if a tel field is empty or
less than x characters.
4
There is no reason to put () here:

Hmm, this depends on which method I use, if the working example I gave in my
previous response is used the () is required!
5
"tel: in the link text will probably get you nowhere, since the usual link
form [skype, mobile phones] is "callto:"

try [you, not me]:

<p>
Phone: <a href='callto:<% = phonNum %>'><%=phonNum%></a>
</p>

On the two web enabled phones I have they work with "tel:", "callto:" is
for Skype
6
and please, do not quote signatures in your responses.
What?

Thanks
M
Evertjan. said:
mettá wrote on 29 aug 2009 in
microsoft.public.inetserver.asp.general:

[Please do not toppost on usenet]

Sorted it now with the help of SRB
The following is the answer!

Perhaps "a", but do not flater yourself bij knowing "the".


<%
phonNum=FP_FieldVal(fp_rs,"tel")

If len(phonNum)>0 then
phonNum=replace(phonNum," ","")

I would remove all the spaces first.
Then an entry like
phonNum = " "
would also work,
and the code is more compact.

=====================================
<%
phonNum = FP_FieldVal(fp_rs,"tel")
phonNum = replace(phonNum," ","")
If len(phonNum)=0 then
phonNum="None"
End If
response.write phonNum
%>
=====================================

Else
phonNum="None">
End If> %>
response.write(phonNum)
%>

This will never work, two %> in succession

Next time copy paste your working code and do not retype, I suggest.


You seem to have a problem with the () logic of VBS.

response.write(phonNum)

response.write phonNum

Statements do not need () around the parameters,
and if there are more than one paramater they cannot have them,
so better NEVER use () as statement parameter delimiters.

A function on the other hand needs them.

phonNum = replace(phonNum," ","")

replace phonNum," ",""

This is just nonsense, because also you did not use the result.

%>

Thanks for trying!

Trying what?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top