Re: [PHP] Saving css state in javascript and passing to php via form submit



On 3/30/07, Tim <user@xxxxxxxxxxxxx> wrote:


> -----Message d'origine-----
> De : Tijnema ! [mailto:tijnema@xxxxxxxxx]
> Envoyé : vendredi 30 mars 2007 17:06
> À : Tim
> Cc : php-general@xxxxxxxxxxxxx
> Objet : Re: [PHP] Saving css state in javascript and passing
> to php via form submit
>
> On 3/30/07, Tim <user@xxxxxxxxxxxxx> wrote:
> >
> >
> > > -----Message d'origine-----
> > > De : Tijnema ! [mailto:tijnema@xxxxxxxxx] Envoyé :
> vendredi 30 mars
> > > 2007 16:56 À : Tim Cc : php-general@xxxxxxxxxxxxx Objet :
> Re: [PHP]
> > > Saving css state in javascript and passing to php via form submit
> > >
> > > On 3/30/07, Tim <user@xxxxxxxxxxxxx> wrote:
> > > > Hello all,
> > > >
> > > > I have a little dilemna here:
> > > >
> > > > I am using php/css/mysql to generate a hierarchical table of
> > > > categories and sub-categories and sub-sub.. Etc..
> > > >
> > > > A screenshot can be found here:
> > > >
> > > > http://www.internet46.fr/mehim/screenshot.jpg
> > > >
> > > > Now i'm also using javascript to hide show blocks of divs
> > > to hide/show
> > > > sub categories.. Typical..
> > > >
> > > > My issue is on page reload, i have a form on the same
> page, when a
> > > > category is clicked, the categorie info displays and you can
> > > > update the info through this form (table and form on
> same page).
> > > > My issue comes when i post the data, the page comes back and my
> > > category tree
> > > > folds up which is normal because all divs are set to
> > > "display:none;".
> > > >
> > > > I have managed to pass a post/get called lastclicked
> that gets the
> > > > nodepath of that element and combined with php to generate
> > > javascript
> > > > that will unfold the tree and highlight the last
> clicked element...
> > > >
> > > > I would like to go one step further and save the entire
> > > state of the
> > > > tree, say several parent categories are unfolded and i click a
> > > > subcategorie to display my form, i want that entire "state" un
> > > > unfolded categories to be displayed not just the clicked
> > > category, of
> > > > course i can get this state and save it in a javascript
> > > array, but my
> > > > issue is when i post my form how do i pass that state data
> > > generated
> > > > by javascript back to the page, to be able to unfold the
> > > tree in the state it was previously?
> > > >
> > > > What are the technologies IF there are any and what should
> > > i look up
> > > > to find docs that cover this type of datatransfer ie:
> > > javascript->php.
> > > >
> > > > Regards,
> > > >
> > > > Tim
> > >
> > > I think you want to use sessions for this :)
> >
> > Ok, i can put the data in the session variable, but i can
> only get the
> > "current" state through javascript
> >
> > ie:onsubmit="getstate()"; which would get the id's of the
> blocks that
> > are set to display:block;
> >
> > But in getstate() how do i pass that to php to set that
> session variable?
>
> You could use AJAX to get things from/to PHP, but why should
> you? You can use session within javascript too i believe.

Hmm javascript setting server-side session data??
Sounds weird, but i'll look into it..
server-side session data? i never heard of server-side sessions...
AFAIK they are send in the HTTP headers from and to the server.
Cookies are nearly the same as sessions, i found this article (with
examples) that goes about parsing cookies from javascript. So you
could also do it with cookies.
http://www.javascriptkit.com/javatutors/cookie2.shtml


> >
> > > Tijnema
> > >
> > > ps. Maybe you could also use AJAX instead of submitting forms the
> > > whole time.
> >
> > In the next version of my framework i would like to, i still havent
> > quite understood the whole concept, not enough research
> yet, but yes
> > i'll be doing that next ;) (you know deadlines, can't sit
> and read docs all day etc..
> > Although i'd rather!)
> >
> > ;)
> >
> > Regards,
> >
> > Tim
>
> Really, it's not that hard to use AJAX. You might want to
> look at www.tizag.com, there it is really easy explained.
> It's nothing more then making new request to scripts inside
> javascript.
Nice tutorial thanks for that, i'll look it up, maybe intergrate it right
away, would really make my day if i could :))

Regards,

Tim

It's not too hard, but if you already did a lot of work on the form
processing, you prefer not to write it all over again i think ;)

Tijnema


.



Relevant Pages

  • RE: [PHP] Saving css state in javascript and passing to php via form submit
    ... to php via form submit ... Now i'm also using javascript to hide show blocks of divs ... Ok, i can put the data in the session variable, but i can ... Maybe you could also use AJAX instead of submitting forms the ...
    (php.general)
  • Re: Decoding html pages
    ... but php blocking of access to the file. ... Let me write up something in a bit more detail (as this is not Javascript ... To get around the stateless nature of HTML one can associate a web session ... in the session variables/session array/session object to change responses or ...
    (comp.lang.javascript)
  • Re: [PHP] Saving css state in javascript and passing to php via form submit
    ... On 3/30/07, Tim wrote: ... >> Now i'm also using javascript to hide show blocks of divs ... >> nodepath of that element and combined with php to generate ... >> that will unfold the tree and highlight the last clicked element... ...
    (php.general)
  • Re: Simultaneous calling two PHP scripts
    ... After data received, the JavaScript ... If I have one XHR in 'wait' state (so the PHP ... subsequent communication with the server. ... you should call session_write_close() before waiting to free up the session for another request. ...
    (comp.lang.php)
  • Re: Decoding html pages
    ... That isn't a javascript trick, but php blocking of access to the file. ... It instructs the server to use PHP code on the server when handling ... it immediately after loading the page without closing the session. ...
    (comp.lang.javascript)