View Full Version : Integrate into FORM
Quiet Storm
03-13-2003, 10:21 PM
Is there a way to get the information document.writed from this JS into a hidden form field?:
<script language="Javascript" src="http://map.geoup.com/geoup?template=welcome"></script>
cheesebagpipe
03-13-2003, 10:43 PM
Sorry about the lament.
Which information? :confused:
Quiet Storm
03-13-2003, 10:55 PM
When the JS is on one's site, it will display the visitors location on the page.
I thought it would be nice to have that information be able to be submitted on a form - when they won't/don't fill out the information, I would still be able to see where they are when the form gets submitted.
Quiet Storm
03-17-2003, 08:39 PM
No takers, huh? :D
cheesebagpipe
03-17-2003, 11:12 PM
I'll take a shot - with more details....:confused:
Quiet Storm
03-17-2003, 11:33 PM
Cool! :D
http://www.geobutton.com/GeoDirection.htm
This site has a way to document.write the visitor's location (prob through SSI). I was hoping to put that information into a FORM. I've viewed the source of the JS, but I just get the end results (nothing I can use, really). Was wondering if I can document.write the JS into the form and have the location of the visitor sent to me.
This is what I see when I view-source:
document.write('<p>Special welcome to our visitors from
<a href="http://www.geobytes.com/FreeServices.htm"
target="_blank">(my city)</a>, United States.</p>');
I'd like "(my city), United States" to show up in the form...
:( I don't think I'm making sense...
cheesebagpipe
03-18-2003, 01:13 AM
Yeah, you are. That geobytes site is quite good - might want to look over their developers (http://epicenter.geobytes.com/HowToArticles.htm) page for some solutions. Came up with this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">
var HTML = '<html><head></head><body><script type="text/javascript" ';
HTML += 'src="http://gd.geobytes.com/Gd?pages=US&ext=html&after=5">';
HTML += '</' + 'script><script type="text/javascript">';
HTML += 'onload = function() {if (typeof sGeobytesLocationCode != "undefined")';
HTML += 'parent.document.forms[0].place.value = sGeobytesLocationCode};';
HTML += '</' + 'script></body></html>';
</script>
</head>
<body>
<form>
<input type="text" name="place">
</form>
<iframe name="dummy" width="0" height="0" src="javascript:parent.HTML"></iframe>
</body>
</html>
Loads the script into an iframe to avoid redirecting the main page. Pretty kludgy approach, and you'd still need some way to map the codes to strings for the actual placenames. Good luck!
Quiet Storm
03-18-2003, 06:38 PM
Oh man, you're good! :thumbsup:
Works like a miracle! Couldn't quite understand the redirect into the iframe, so I did some creative editing (maybe I'll learn something from it):
<script type="text/javascript" src="http://gd.geobytes.com/Gd?pages=US&ext=html&after=-1"></script>
<script type="text/javascript">
onload = function() {if (typeof sGeobytesLocationCode != "undefined")
parent.document.forms[0].place.value = sGeobytesLocationCode};</script>
<form>
<input type="text" name="place">
</form>
Changed the redirect timer to -1, and removed the iframe, then sorted through the code and placed it as is...
:D
Thanks again CBP! You're the brain!
cheesebagpipe
03-18-2003, 10:06 PM
Without seeing the program running on their server - I'm guessing it's in Perl - it was difficult to figure out some way of voiding the redirect, since the JS document.write()s it into the page. So I bypassed the issue by writing it into a different document. Kudos for figuring out that business with the negative GET argument. You are good.
Quiet Storm
03-18-2003, 10:54 PM
I was wondering... where'd you find the URL?:
http://gd.geobytes.com/Gd?pages=US&ext=html&after=5
I couldn't find it (or any other info) about it on their pages... :confused:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.