heh you don't mind the odd JS do ya steve ;) (which is good).

Problem:
Increase the font-setting to say 19pt and you start seeing the problem (not that any sane person would do that - but illustrates the problem still).


I've been doing some brief looksies on google alike etc, and so far i'm yet to find what exactly IE/FireFox uses to render fonts within Input boxes (whether they do them or they leverage off of the O/S). Plus what happens below in Mac? Anyone test that out as that would be interesting to see those results aswell.

I've always found (flash mx, .NET Windows Forms etc) that Input fields never really follow a set formula, if its not the padding, its the damn character size that screws you in the end.

Heres the closest link so far, in my quest in answering the annoying question "but why?.." - that kids love so well.

http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerProgrammingBugs


Regards Scott Barnes (Splash 1.0 N00bie / Allaire 3.0 Script Kiddie)


Steve Onnis wrote:
Here I got bored

<style>
        input {font-family:arial; font-size:9pt;}
        #fieldData {font-family:arial; font-size:9pt; padding:2px;}
</style>
<script>
        function setSize(obj) {
                document.getElementById("fieldData").innerHTML = obj.value
                obj.style.width = 
Math.max(100,document.getElementById("fieldData").offsetWidth);
                }
</script>


<div id="fieldData" style="width:auto; visibility:hidden; border:2px inset; position:absolute; "></div> <input type="Text" name="field1" style="width:100px;" onkeypress="setSize(this)" onkeydown="setSize(this)"><br> <input type="Text" name="field2" style="width:100px;" onkeypress="setSize(this)" onkeydown="setSize(this)"><br> <input type="Text" name="field3" style="width:100px;" onkeypress="setSize(this)" onkeydown="setSize(this)"><br> <input type="Text" name="field4" style="width:100px;" onkeypress="setSize(this)" onkeydown="setSize(this)"><br>



Hope it helps somewhat

Steve

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Velevitch
Sent: Monday, November 01, 2004 7:52 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: How to autosize a form field?

On Mon, 1 Nov 2004 19:25:27 +1100, Ben Smith <[EMAIL PROTECTED]> wrote:

I agree there's no correlation between size and maxlength. Since this is an input field, and provided the maximum number of characters is not too large, wouldn't the size best be equal to maxlength, the maximum number of characters allowed for the field? My reasoning is that if the value is changed and the new value is longer than the field size, then the browser will horizontally scroll the value in the field. I believe horizontal scrolling tends to be awkward for most users.


Chris


I have a feeling they're not 1:1, it's not really possible (at least
it wasn't when I last tried, a year or two ago) to do it and get it
right with any certainty. That should yield a decent result that is
certainly better than nothing.


On Mon, 1 Nov 2004 16:51:18 +1000, Jon Austin <[EMAIL PROTECTED]> wrote:


Do you mean:

<input type="text" name="blah" value="#defaultvar#" size="#Len(defaultvar)#">

I'm not sure if the number of characters and the size attribute are 1:1.




On Mon, 01 Nov 2004 17:45:02 +1100, Ayudh Nagara <[EMAIL PROTECTED]> wrote:


Is there a simple way to autosize a form field so that it is just wide
enough to accommodate the text value at page load time (as specified

in

VALUE parameter)?

--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/





---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/




--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to