Kenny Pollock
Apr 21 2006, 03:15 PM
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
Apr 21 2006, 03:23 PM
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
Apr 22 2006, 03:06 PM
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
Apr 22 2006, 03:27 PM
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
Apr 22 2006, 03:42 PM
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.