Frank and Eddie are right about not being able to read the css property unless you have set it ahead of time. The javascript Element Object (from which buttons etc are derived) has properties called clientWidth and clientHeight. This will give you the width and height of the element in pixels as rendered on the client. Hopefully that helps!

document.getElementById('b').clientWidth

-Adam

Eddie Bush wrote:
Frank,

I don't think you could extract the width from the control's style unless you'd set it. I'd have to agree with you on that one. Isn't there a property on the control (width?) you could determine the width from? Maybe I answered too quick and should have done some research first. I was thinking I had done something similar before, but as I dig deeper into my memory I realize that it was the height of an iframe I set, and that was based off the contained document's height (scroll height or some such thing).

I suppose it seemed intuitive to me that the button should have a width. I'll dig into my JavaScript book while at the office tomorrow and see if there isn't a property that a person can determine the width of a button with. There's got to be a way to do it. I'm curious now, too! I have been wrong before though.

I'll try to pop-in at lunch and drop my findings ;-)

Eddie

----- Original Message ----- From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Sunday, June 18, 2006 4:50 PM
Subject: Re: How to set size of submit button


Would that even work Eddie? I seem to remember that if you didn't explicitly set the width of an element yourself, you can't retrieve it. Indeed, this quick test:

<html>
<body onload="alert(document.getElementById('b').style.width);">
<input type="button" id="b" value="this is a test">
</body>
</html>

..results in a blank alert in both IE and FF.

This only matters of course if you have to make all the buttons the same width dynamically, but now I'm just curious! Is there a way to do it I wonder?

Frank


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to