Showing numbers from a db with/without a gap

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 be xxxxxxxxxxx (no spaces)

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

Thanks
M
 
T

Trevor Lawrence

mettá said:
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 be xxxxxxxxxxx (no
spaces)

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

Are they stored as character?

If so, use a simple JavaScript substring

e.g.
<script type="text/javascript">
document.write(str.substring(0,4) + " " + str.substring(5));
</script>

where str contains the 11 character value extracted from the database
 
R

Ronx

Use code to remove the spaces from the mobile pages, and leave as is for
non-mobile pages.

In classic asp (must be adapted to the script language you are using):

'get telephone from database and store in variable phoneNumber
'set mobilePage = true if page is for a mobile, otherwise set to false
if mobilePage then
replace(phoneNumber, " ", "")
end if
response.write(phoneNumber)


--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
M

mettá

Can you help me with the syntax to do this as I can't get it working...

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

replace(phonNum," ","")

response.write(phonNum)

%>

Thanks
M
 
R

Ronx

I cannot see anything wrong with the syntax. Is this code segment within a
DBR region or outside it? If outside, the fp_rs value may have been set to
nothing, or not yet set to anything - what errors are you getting?

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
M

mettá

The error is

Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/SITE_Aug07/m/page2.asp, line 106, column 23
replace(phonNum," ","")

Any sugestions?
Thanks

M
 
R

Ronx

It's more likely the error refers to the response.write statement - try this
without the brackets:

response.write phonNum

I use vb.NET - not the same as vbScript - which always requires brackets,
and examples at w3schools show the brackets as well, but from
http://codingforums.com/showthread.php?t=76925

<quote>
VBScript in Classic ASP is a little weird in that you only use parentheses
when calling functions (that return a result), not when calling subs (that
just do something, without returning a result).
</quote>

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
S

Stefan B Rusynko

Should be

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


--




| Can you help me with the syntax to do this as I can't get it working...
|
| <%
| phonNum=FP_FieldVal(fp_rs,"tel")
|
| replace(phonNum," ","")
|
| response.write(phonNum)
|
| %>
|
| Thanks
| M
|
|
|
| | > Use code to remove the spaces from the mobile pages, and leave as is for
| > non-mobile pages.
| >
| > In classic asp (must be adapted to the script language you are using):
| >
| > 'get telephone from database and store in variable phoneNumber
| > 'set mobilePage = true if page is for a mobile, otherwise set to false
| > if mobilePage then
| > replace(phoneNumber, " ", "")
| > end if
| > response.write(phoneNumber)
| >
| >
| > --
| > Ron Symonds
| > Microsoft MVP (Expression Web)
| > http://www.rxs-enterprises.org/fp
| >
| > Reply only to group - emails will be deleted unread.
| >
| >
| >
| > | >> 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 be xxxxxxxxxxx (no
| >> spaces)
| >>
| >> I can edit the db to remove the spaces BUT would like then to display on
| >> the fp site with a space. Anyone know a simple solution???
| >>
| >> Thanks
| >> M
| >>
|
|
 
M

mettá

Thanks for continuing to try and help but...

If I do this

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

Then I get

Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/SITE_Aug07/m/page2.asp, line 106, column 23
replace(phonNum," ","")
----------------------^

If I do this

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

It produces 1234 567891 so the replace " " does not work

What am I doing wrong?

M
 
R

Ronx

Sometimes the obvious escapes us...

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

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 

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

Top