0

I have a form that takes a zipcode as input and displays a google map on the same page using ajax.

If I submit the form using a submit button, it works fine.

However, I would like to auto submit the form after 5 characters are entered.

This code works fine to submit the form:

<form id="zip" action="zip.php" method="post">
zip code: <input type="text" name="zipcode" onKeyUp="if(this.value.length>4)this.form.submit()">
</form>

but without using the submit button, it does not query zip.php replace the div on the current page with the google map. All it does is load the action page, zip.php.

Why does it work fine with a submit button, but not with this.form.submit

This has been driving me crazy!

Thank you!

3
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by Airshow
0

ASG,

Form submission makes a regular (non-ajax) HTTP request so if you want ajax, ensure that the form is not submitted.

If the submit button performs ajax, then the code for onKeyUp should be similar.

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.