How to get onchange to update immediately?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeredDrahcir
    Contributor
    • Nov 2009
    • 426

    How to get onchange to update immediately?

    I have a form that specifies the width and height of an image. I also have an option that says 'Maintain Aspect Ratio'.
    If they click on that then the height and width boxes operate an onchange event so that when one is changed, it changes the other to keep the aspect ratio. Is there a way to update the other value if the user changes on then clicks submit since you have to click outside the box for the onchange to work.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    is it a checkbox? you might try to use the onclick-event instead.

    Comment

    • KeredDrahcir
      Contributor
      • Nov 2009
      • 426

      #3
      I'm using a tickbox. However the tickbox has the option to Maintain Aspect Ratio. I'm able to check whether it's ticked. The width and height values are input boxes, so that if one is changed, the other needs to change.

      I could do this that when they click on Save it looks at the Maintain Aspect Ratio box and if it is ticked then it makes sure the Aspect Ratio is correct and if it isn't it sorts it out. I'd rather not do it that way becuase you need to know which was the last value to be changed and as far as I can see, the only way to do that is with an onchange again which brings me back to the original problem.

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        What about using the onkeyup event? This way it updates after each number entered into the textbox.

        Comment

        • KeredDrahcir
          Contributor
          • Nov 2009
          • 426

          #5
          That's brilliant. Just what I need (if it works). I'll let you know. I'll give it a try first thing tomorrow.

          Comment

          • KeredDrahcir
            Contributor
            • Nov 2009
            • 426

            #6
            Works like a charm. Many thanks!

            Comment

            Working...