[thelist] JS: Snippet to grab GET/POST value?

Jeff Howden jeff at jeffhowden.com
Mon Aug 18 17:41:43 CDT 2003


frank,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Frank
>
> I have an administrative page with lots of form
> information broken up into logical divs (clients
> info, address, contact information, pop information
> and so forth).  [Visual description best seen in
> mono-spaced font.]
>
> At the top of the page I have a "function bar" where
> clicking on a name (ie: Notes) changes the class of
> a div from hidden to visible.  All divs are "hidden"
> by default, and display only when it's name on a
> "function bar" is clicked.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

make a note to yourself to avoid changing classes whenever possible.  it's a
very "expensive" operation that can usually be avoided by changing just a
few or even just one style property value.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Problem is when I submit a form and it reloads, all the
> divs are hidden by default, and thus it's a disconnect
> for the user. I want to append the values of the visible
> divs to a url with the values of "on" or "off" so
> that on reload, the divs that were open show as such.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

i don't quite understand what you mean by "when i submit a form and it
reloads".

are you talking about if there are errors you show the form to the user
again, but with error messages?  or, are you talking about a redirect back
to the form after the user has successfully saved some changes?

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> I might have something like this
>
> ?notes=on&contact_info=on
>
> so that on reload these divs "un hide" themselves, as
> the user had before form  submission.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

if this "reload" is the result of a redirect, then i'd pass the name of the
sections to be shown as a list.  something like:

?show=notes,contact_info

then, i'd use this list in some sort of function called by the onload event
handler to toggle the sections in that list.

alternatively, you could make the section more accessible by starting out
with them being all visible by default.  then, in the code at the bottom of
the page toggle just the ones that don't exist in the list passed in the url
to hidden.  the reason for not using the onload in this case is that
there'll be a brief moment between when the page is loading, the user sees
all the forms, and then the page collapses as it hides all of them.  if you
put the script inline immediately after the last of the form sections, the
user probably won't even see them.

.jeff

------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/




More information about the thelist mailing list