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/