Help - Search - Members - Calendar
Full Version: Javascript+PHP
Invision Power Services > Community Forums > Community Web Design and Coding
Kenny Pollock
Hey guys!

I'm developing an application for an auto transporter, and made a quick script to read Google Maps and find the distance between two cities and states in miles.

When they make an order, they fill out a city, state, zip for the origin and destination. What I want to do is when they fill out the destination, check if the origin city and state are filled out and if they are, goto blah.php?origin_city=Levittown&origin_state=PA&destination_city=Hollywood&destination_state=FL and display the 1,200 miles it echos.

Problem is... I don't know Javascript, any help?
Starnox
I'm not amazing at it but something like:

CODE
function toggle(field)
{
     if (field.value.length==0 || field.value==null)
     {
          window.document.forms["form_name"].elements["submit_button"].disabled = true;
     }
     else
     {
          window.document.forms["form_name"].elements["submit_button"].disabled = false;
     }
}


Then do an onChange linking to toggle. This will only check that single field though, so you will have to modify it to check all three fields.
Kenny Pollock
Thanks, but you misunderstood my post, I didn't want to disable any submit button.

I came up with http://everglademedia.com/clients/directco...emplates/miles/ - you can test it out by filling out all four and then getting out of focus on the last one. It will parse Google Maps for the mileage.
_
Just a little thing, this looks very user-unfriendly to me. What if the last (select) field is already set to the correct thing (the first value), and the user doesn't want to focus then blur it?
Kenny Pollock
It's for a program I'm coding for a transport company. They will be tabbing over all four fields when they create an order... it won't be selected before the other ones are.
_
That's not what I meant; if the last box isn't selected, there never is a result. What if "Destination State" is in fact "AL"?
Kenny Pollock
QUOTE(Veracon @ Apr 22 2006, 11:38 AM) *
That's not what I meant; if the last box isn't selected, there never is a result. What if "Destination State" is in fact "AL"?

They would still be tabbing past it to get to the input fields below it, therefore activating the onblur, and providing the mileage.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.