[thelist] onchange.. my aunt!

Mark Groen evolt at markgroen.com
Tue Jan 30 10:00:52 CST 2007

On Tuesday 30 January 2007 02:07, Tris wrote:
> Hi all...
> going back to basics today..
> I've got a form.. (a form!) that s giving me grief..
> I want the form to self submit when I change a SE:ECT option.

Holey moley Batman, I would get no where with that form as I'm always 
selecting the wrong item in a select list and often have to go back and try 
again. At least make the form work without javascript so a person can try 
again if they are having problems.

> top of my form:
> <form id="bookingForm" name="bookingForm" method="post"
> action="<?=$_SERVER['REQUEST_URI']?>">

Please get out of the habit of using old style ASP "short" tags, that stopped 
being a default with php back around version 3 I think... On a modern 
production server these most likely will be turned off and it will save some 
headaches if this form example is used elsewhere than localhost. There are 
lots of reasons of why it's bad to use short tags with a quick Google.

echo '<form action="'.$_SERVER['PHP_SELF'].'?action="checkthisformsinput" 

> and further down..
> <select name="departure" id="departure"
> onChange="document.forms['bookingForm'].submit(); return true;">

Please put a "go" button beside this element so those with motor skill 
problems, the blind, people like me, etc. etc. can use your form too! Also, 
it tells people that are good with a mouse that something is going to happen 
via that field even if they don't use the "go" button.

> i've tried using this:
> this.form.submit();
Lee has what should be the correct syntax in another post: 

You *should* be doing some error checking, put something like this at the top 
of the file before any html:
if(isset($_GET['action']) AND $_GET['action'] == "checkthisformsinput"){
// all the things you want to do ...

> "As for accessibility.. my client doesn't care.. it's a 'quick and nasty' 
> job...If there's time after, i'll re-investigate though..."

But your clients customers may care and I don't think it's necessary to go 
into the moral implications of denigrating yourself into doing something wrong 
just so you can make a buck. There is no such thing as "if there's time 
after" - there never is. The time is now to learn how to do this proper so 
you can "do the right thing" next time.

It's not that hard to make forms accessible:

Do some tutorials from the results of above search, then create a form with 
every form element in it that also self submits (echo the values of the form 
after it runs so you know it's working as intended) and save it in your 
snippet library. The next time, you can just copy/paste the elements you need 
for your next form from your snippet library and form building will go 
lickety split.



More information about the thelist mailing list