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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I pass GET data without using a form?

Status
Not open for further replies.

dcnguyen

Technical User
Mar 22, 2005
54
US
OK, on my form.html page, I have a field where someone can type in an address. My intent is to geocode this address and pass the address, latitude, and logitude to the php page...unfortunately, all I know how to do is pass variables using form/submit.
 
javascript?
but why not use a form anyway? if you have a text box adding the form tags should be transparent to the user.
a form that sends using the GET method effectively appends a query string ?key=value&key2=value2 to the end of the url.
 
Right...My problem is, is that I don't understand how to append to the url AFTER doing some processing on the form input. What I specifically want to do is have the user enter an address and upon hitting submit, take that address, submit it to Google's geocoder (through Javascript), retrieve the lat/long coordinates, and then pass those and the address to the php page.
 
I would think that a simple method would be something like an onSubmit caller function. It would go something like this

<form name='my_form' action='whatever' method='post' onSubmit='return geocode_function(address);'>

then make sure you have the javascript geocode_function(name it whatever you want) function created...

geocode_function(address_info)
{
send the address_info variable to google, and retrieve the info they give back to you.

then I would recommend that you change a hidden value in your form, such as:
document.my_form.hidden_geocode_element.value='whatever you retrieved from google'

then, after you have set that info, make sure you have:

return true;

at the end of your javascript function.


Basically what happens is that the user clicks submit, the data is passed to google, then google processes and returns the geocode date, you then add this data to the form via javascript, and then the return true tells the form that everything is ok and that it can now submit the form to the next place.


Hope this helps, but if not, I'd be happy to construct a working model, but I'll need some source code from you.

Exactly where is the point that you are assassinated rather than murdered?
 
I would think that a simple method would be something like an onSubmit caller function. It would go something like this

<form name='my_form' action='whatever' method='post' onSubmit='return geocode_function(address);'>

then make sure you have the javascript geocode_function(name it whatever you want) function created...

geocode_function(address_info)
{
send the address_info variable to google, and retrieve the info they give back to you.

then I would recommend that you change a hidden value in your form, such as:
in the form-><input type='hidden' name='geocode'/>

in your javascript->document.my_form.geocode.value='whatever you retrieved from google';

then, after you have set that info, make sure you have:

return true;

at the end of your javascript function.


Basically what happens is that the user clicks submit, the data is passed to google, then google processes and returns the geocode data, you then add this data to the form via javascript, and then the return true tells the form that everything is ok and that it can now submit the form to the next place.

Then, on the page the receives the form, you simply retrieve the information from that hidden form element.
Hope this helps, but if not, I'd be happy to construct a working model, but I'll need some source code from you.

Exactly where is the point that you are assassinated rather than murdered?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top