Solved

parse out text typed in one text box into two separate text boxes

Posted on 2008-10-20
4
253 Views
Last Modified: 2012-05-05
I have a text box that users paste GPS cordinates into.  They enter :
Latitude: 42.079964  /  Longitude: -71.869398
into field "GPSCOORDINATES".  I would like it parsed out into two separate fields : Latitude & Longitude.
any ideas ?

Regards,
Mark
0
Comment
Question by:drelinger
4 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22759502
you can split it into an array

arrayVairable = Split(FormFieldWithGPS, '/')

this should give you a 2 array variable then you would acccess it like this:

Lattitude = arrayVariable[0]
Longitude =  arrayVariable[1]

0
 
LVL 16

Accepted Solution

by:
sh0e earned 500 total points
ID: 22759584

<script>

function parseGPS(gps_string){

	matches = gps_string.match('Latitude: (-?[0-9]+\\.[0-9]+)  /  Longitude: (-?[0-9]+\\.[0-9]+)');

	if(matches == null || matches.length != 3){

		alert('invalid GPS coordinates');

	}

	else{

		var latitude = matches[1];

		var longitude = matches[2];

		alert(latitude + ":" + longitude);

	}

}

</script>
 

<input type="button" value="grab GPS" onClick="parseGPS(document.getElementById('GPSCOORDINATES').value);"></input>

<input type="text" id="GPSCOORDINATES"></input>

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22759587
try:
Dim str
str="Latitude: 42.079964  /  Longitude: -71.869398" 
data = Split(str,"/")
data(0)=split(trim(data(0))," ")
data(1)=split(trim(data(1))," ")
Dim latitude,longitude
If "LATITUDE" = Left(Trim(UCase(data(0)(0))),8) Then
	latitude = data(0)(1)
	longitude= data(1)(1)
Else
	latitude = data(1)(1)
	longitude= data(0)(1)
End If 
Response.Write( "Lat: " & latitude )
Response.Write( "Long:" & longitude )

Open in new window

0
 

Author Closing Comment

by:drelinger
ID: 31507884
I think all of the answers would work, but I felt this solution was the best.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scheduled IIS .Net2 AppPools recycle and SQL connection Hangs 33 93
SharePoint 2013 Blog Template 2 37
Why does my button disappear? 3 29
Objects on Same Line 2 18
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now