Reply to Re: Question about forms

Your name:

Reply:


Posted by Jukka K. Korpela on 06/10/06 07:45

Martin Jay <martin@spam-free.org.uk> scripsit:

> In your HTML form you'd have something like this to create the
> drop-down box:
>
> <select name="email">
> <option value="1">Email address 1</option>
> <option value="2">Email address 2</option>
> <option value="3">Email address 3</option>
> </select>

Any <select> element (except those with the 'multiple' attribute set) should
have one option preselected, normally a "dummy" option, to avoid getting
browser-dependent default data if the user does not make any selection and
to avoid defaulting to the first option even when you don't mean that.
Therefore, add the following as the first option:

<option value="0" selected>Please select the destination address:</option>

> And then in the script that receives the form you would use logic such
> as like:
>
> if name = 1 then email form to 1@spam-free.org.uk
> if name = 2 then email form to 2@spam-free.org.uk
> if name = 3 then email form to 3@spam-free.org.uk

Well, you would probably want to test "email" (the actual field name) rather
than "name".

In actual programming, you would probably want to use an array or a hash of
addresses and simply pick up an address using "email" as an index to it -
_after_ checking that the value is an integer that is within the specified
bounds.

And you may wish to check against the case where "email" is none of 1, 2,
and 3. The value 0 should probably be treated gracefully as a user input
error. Other values might be treated as potential cracking attempts, so the
implicit error processing of not doing anything (data ignored, no data sent
anywhere) might be quite adequate.

P.S. I have an uncanny feeling that the OP wanted to do the job without any
kind of server-side scripting. Then the answer is "don't".

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация