RE: Dynamic form changes without refresh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I suppose that, as well as updating the database when I click the link, I
could also update a CSS toggle, but I'd really like it to be deciding
whether to toggle only based on the flag in the database.

So:

// check database
if ($toggle == 1)
{
   <textarea>...</textarea>
}
else
{
   <textarea disabled>...</textarea>
}

This is called every time the page is refreshed, of course, but if the
database is changed afterwards, the form doesn't know. I would like some way
of continually checking in the background whether $toggle is 1 or 0, and
update the form appropriately. I assumed AJAX was the way to go.

Perhaps I'm making this more complicated than it needs to be, but there is a
reason why I want to store the state of the toggle in the database (as
opposed to simply using a javascript on/off snippet) as I use this
information in other places in the code.

-----Original Message-----
From: Per Jessen [mailto:per@xxxxxxxxxxxx]
Sent: 05 June 2008 13:26
To: php-general@xxxxxxxxxxxxx
Subject: Re:  Dynamic form changes without refresh


Mayer, Jonathan wrote:

> Using some basic javascript/AJAX, I have set up a link next to each
> text box, which calls code that updates the database in the background
> without refreshing the page. If I manually refresh the page, the
> textarea box in question updates correctly, proving that the database
> update has worked. However, I cannot work out how to get the textarea
> boxes to toggle the disable on/off "on the fly". I assume they would
> need to continually check the database and adjust as required.

This sounds too obvious, so I've probably misunderstood your question -
but surely it is just a matter of toggling the CSS 'display' attribute? 


/Per Jessen, Zürich


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux