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

Ian Munday ian.munday at illumen.co.uk
Thu May 25 21:16:30 BST 2006



----
Ian Munday
Illumen Ltd.
www.illumen.co.uk

T:  +44 (0)121 703 3111  /  +44 (0)845 00 999 00
E:  ian.munday at illumen.co.uk



On 25 May 2006, at 20:22, Phil Beynon wrote:

>>> 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!

NaN is a special value representing 'Not a Number'.  It will be  
returned because you are attempting a numeric calculation on a non- 
existent value (or an empty string) in text1.  Suggest you either  
perform some input validation, or handle this error in some other way.

Ian




More information about the Phpwm mailing list