Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse Data 1

Status
Not open for further replies.

dnayana

Programmer
Nov 14, 2002
53
US
I have four input fields (i.e. txtIntlPhoneNo1, txtIntlPhoneNo2, txtIntlPhoneNo3, and txtIntlPhoneNo4) that contains data for an International Phone Number. Input fields "txtIntlPhoneNo1" and "txtIntlPhoneNo2" are static fields (99 and 011 respectively). "TxtIntlPhoneNo3" contains the Country Code (which varies in Len) and "txtIntlPhoneNo4" contains the remaining digits of the phone number.

The data is saved in the db within one field (i.e. txtPhoneNo). Data may appear as 99 011 93 123456666.

What I would like to do is look for the first "space" found (after 011), then extract that data within its appropriate field (i.e. txtIntlPhoneNo3") up until where the second space is found and extract that data within its appropriate field (i.e. txtIntlPhoneNo4).

I'm currently using the Mid & Right functions, but that is currently not working. Finding that the Len(txtPhoneNo) will vary. I think finding where the a space exists and extracting that data will probably be more efficient.


Code:
<cfscript>
...
variables.txtIntlPhoneNo3=Mid(qryRequesters.txtPhoneNo,8,3);
variables.txtIntlPhoneNo4=Right(qryRequesters.txtPhoneNo,16);	
</cfscript>

<!--- Dialing Out Prefix --->
<input type="text" name="txtIntlPhoneNo1" maxlength="3" size="1" value="99" onfocus="promptEntry(stxtPhoneNo)">&nbsp;-&nbsp;

<!--- Intl Dialing Prefix --->
<input type="text" name="txtIntlPhoneNo2" maxlength="3" size="1" value="011" onfocus="promptEntry(stxtPhoneNo)">&nbsp;-&nbsp;

<!--- Country Code --->
<input type="text" name="txtIntlPhoneNo3" maxlength="5" size="6" value="#Variables.txtIntlPhoneNo3#" onfocus="promptEntry(stxtCountryCode)">&nbsp;-&nbsp;

<!--- Remaining Digits of Phone Number --->
<input type="text" name="txtIntlPhoneNo4" maxlength="16" size="20" value="#Variables.txtIntlPhoneNo4#" onfocus="promptEntry(stxtPhoneNo)">&nbsp;&nbsp;


Any assistance that can be provided is greatly appreciated. [ponytails2]
 
if there will always be data in each of those fields, treat the whole thing as a list separated by spaces, then use the ListGetAt(txtPhoneNo,1," ") would give you the 99, ListGetAt(txtPhoneNo,2," ") would give you the 011 etc..


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top