checking a value in RJS

Basically I want to toggle the value of an element on a page via RJS.
I can set the value fine, but I simply cannot figure out how to check
the current value. This is essentially what I want to do:

if page["element_id"].value == "0"
  page["element_id"].value = "1"
  page["element_id"].value = "0"

The assignment lines (e.g. page["element_id"].value = "1") work fine.
It's that line to check the current value of the element that is
killing me.

Any experience with this?

(Note: I have the RJS Templates for Rails PDF "book", but there is no
mention of detecting or assigning values. And as usual, there isn't
much else out there on the 'Net.)

Thanks. I was thinking about your suggestion, but I did not wish to go
on a wild goose chase and I couldn't find any confirmation for the idea
out on the 'Net. Anyway, it looks like the above pretty much solves
the problem.