onpropertychange for firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bogdang20
    New Member
    • Sep 2007
    • 4

    onpropertychange for firefox

    Hello,

    I have a piece of code written for IE that uses onpropertychang e. I want to make the code work on Firefox also, but i couldnt find an equivalent event that fires when the value is changed in JS scripts and i need help.

    My problem is this. I have 2 html elements: an input type hidden that keeps the value which will be posted and an UI value (type=text) that shows the value to the user. What I need to do is to syncronize the modifications for these two values: when the hidden element is changed, the UI value is changed and vice-versa.

    My script for IE :

    [CODE=javascript]<public:attac h event="onproper tychange" onevent="handle PropertyChange( )"/>
    <script language="JScri pt">
    function handlePropertyC hange() {
    if (event.property Name == 'value') {
    syncronize hidden element with UI
    }
    }
    </script>[/CODE]


    and something similar for the UI element. The above code fires when I do :

    [CODE=javascript]function someFunction(el ) {
    el.value = 5;
    }[/CODE]
    and makes the UI value also 5 (and vice-versa).



    Really, my question is how can i know when the value of the hidden element was changed somewhere in some JS script (and works on FF also) ?

    Thank you,
    Bogdan
    Last edited by pbmods; Sep 21 '07, 10:32 PM. Reason: Changed [CODE] to [CODE=javascript].
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    please note that there is no such thing as "JScript" in standard HTML. Change this to <script type="text/javascript">

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      onpropertychang e is IE-only. Use onchange instead. This may not do exactly the same thing though, so you'll have to accommodate that in your code.

      Comment

      • bogdang20
        New Member
        • Sep 2007
        • 4

        #4
        Originally posted by acoder
        onpropertychang e is IE-only. Use onchange instead. This may not do exactly the same thing though, so you'll have to accommodate that in your code.
        I know about onpropertychang e being IE-only (I used behaviour handlers in IE .htc files). What I want to know is what event for mozilla must i register with my elements in order to execute my functions when the value of a property is changed from within a javascript function (for example I change the value of the hidden, the event gets fired and executes my syncronization functions). Onchange doesnt fire when i change the value of the hidden from a JS function.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          hi ...

          may be its:

          Code:
          onDOMAttrModified
          what you are after. have a look here at the w3c for mutation events.

          kind regards

          Comment

          • bogdang20
            New Member
            • Sep 2007
            • 4

            #6
            Originally posted by gits
            hi ...

            may be its:

            Code:
            onDOMAttrModified
            what you are after. have a look here at the w3c for mutation events.

            kind regards
            Thank you, that seems to be the event I need. I doesnt work in IE though and I'll need to make cross-browser scripts.

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5390

              #7
              hi ...

              of course ... but now you have everything to do it or not?

              kind regards

              Comment

              • bogdang20
                New Member
                • Sep 2007
                • 4

                #8
                Yes, I have what I need now. Thank you.

                Comment

                • gits
                  Recognized Expert Moderator Expert
                  • May 2007
                  • 5390

                  #9
                  :) ok ... post back to the forum anytime you have more questions ...

                  kind regards

                  Comment

                  • sakthipro
                    New Member
                    • May 2007
                    • 18

                    #10
                    Originally posted by bogdang20
                    Yes, I have what I need now. Thank you.
                    Hi, I have the same situation,
                    Could you tell me the solution pls.

                    Thanks in advance
                    Regards,
                    Sakthikumar

                    Comment

                    • helimeef
                      New Member
                      • Sep 2007
                      • 77

                      #11
                      Originally posted by sakthipro
                      Hi, I have the same situation,
                      Could you tell me the solution pls.

                      Thanks in advance
                      Regards,
                      Sakthikumar
                      Read the entire thread. It's RIGHT THERE. And it's spelled "please".

                      Comment

                      • robothero
                        New Member
                        • Sep 2008
                        • 1

                        #12
                        Originally posted by helimeef
                        Read the entire thread. It's RIGHT THERE. And it's spelled "please".
                        Yeah thanks that really helped me out but let's not be so pedantic, isn't it 'spelt' instead of 'spelled'?"

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          No, both regular and irregular forms are used, though one more than others in places.

                          Anyway, back on topic, to make cross-browser scripts, try the standard mutation events first. If they're not supported, try using onpropertychang e.

                          Comment

                          Working...