[Phpwm] [OT] Any ideas how to do this?

Phil Beynon phil at infolinkelectronics.co.uk
Thu May 25 20:23:13 BST 2006

> > I have two text boxes within a form and a radio button.
> > There is a ratio between the values of the starting values within the  
> > text
> > boxes, which is actually the aspect ratio of an image. The function of  
> > the
> > radio button is to say overide the aspect ratio.
> >
> > If the radio button isn't set and one of the text box values is 
> altered I
> > want the value of the second box to alter to the same (interger value)
> > ratio. If the radio button is set I dont want the value of the second  
> > box to
> > alter.
> Hi,
> Some code for you at:
> http://www.phpwm.org/pastebin/index.php?id=49
> It assumes the text-areas have values in them to start with, and 
> initially  
> this is the ratio used for further changes.
> If you change one value with the checkbox unticked, then the ratio is  
> recalculated, so upon re-ticking it, this new ratio is used for  
> calculations (experiment and see if that doesn't make sense...).
> As one of the comments mentions, if this is going in anything 
> larger than  
> <something very small>, then using window.onload directly is 
> probably not  
> a good idea.
> Greg Jones

Cheers Greg,
That's actually very near what I wanted indeed. Is there a way of making it work both ways text1 -> text2 as now and also text2 -> text1 onchange?

Couple of oddities on it though that I noticed - 
On the default starting value of 300/200 if you put a leading zero in front of the 300 then the 200 drops to 128 for some reason.

If there is no content in text1 text2 says "NaN" for some reason!


More information about the Phpwm mailing list