NYCPHP Meetup

NYPHP.org

[nycphp-talk] Dynamic Form Elements

Jake McGraw jmcgraw1 at gmail.com
Fri Feb 1 09:22:52 EST 2008


I'd create the form normally, with the optional select visible, but
the first value of the optional select list stating "Applicable only
for value XYZ". Then I'd use JavaScript to hide the optional select
list, remove the "Applicable only for value XYZ" and detect an
onchange event on the first select list for determining visibility for
the optional select list. This way, if your user is one of the 6% of
internet users without JavaScript turned on, at least the second list
will make some sense. When the request gets sent to the server, always
check both values and make sure it makes sense. I always try to
develop my web applications / forms entirely in HTML first and make
sure it works without javascript, then I add javascript where it makes
sense for a better user experience.

- jake

On Feb 1, 2008 6:42 AM, David Krings <ramons at gmx.net> wrote:
> Michael B Allen wrote:
> > What's the best, most portable way to do this?
>
> There is likely a better way, but what I do (and I think I needed it once) is
> to simply reload the page and evaluate the submission. Ugly, but it works and
> it is definitely portable. You can either do an automatic self-submit (not
> section 508 compatible...as most of the Web2.0 stuff) or wait for the submit
> button to be clicked.
>
> David
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>



More information about the talk mailing list