forms and actions

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

    I'm building a form which looks like this:

<Submit> = clicking this is going to update my database.

But before the user clicks submit, I want to provide more choices for
her based on the zipcode. So if the zipcode is 95135, I want to provide
a list of restaurants in and around the 95135 area. Is this possible,
if so how?


Re: forms and actions


Quoted text here. Click to load it

In HTML, you don't.

Some people will suggest using JavaScript, but that would fail for a
considerable number of users and would require that the logic be built into
files that are sent to the browser.

The constructive way is to make things work so that the initial form's
submit button sends the data to preprocessing only, so that the form handler
will check the zipcode and send back a new form, containing the already
filled-in data as hidden fields (possibly duplicated as text content on the
page, for reference for the user) and some additional field(s) to be filled

Jukka K. Korpela ("Yucca")

Re: forms and actions

Sweet. I was looking at Javascript initially, but didn't really like
the idea.


Jukka K. Korpela wrote:
Quoted text here. Click to load it

Re: forms and actions wrote:

Quoted text here. Click to load it

Go and read up on AJAX

It's now fairly easy to do this, i.e. there are many worked examples on
how to do it with with good, well-behaved and well-portable code.

It doesn't work if JavaScript is turned off, but you should also find
examples of how to cope with this transparently. Of course it's slower
for the user and it puts more load on your server (the <form> gets
submitted and re-filled whenever you select a new area code) but it
does work.

Site Timeline