# Possible to get the Width of a form in Javascript?

**URL:** <https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851>\
**Category:** Classic Servoy\
**Created:** [October 7, 2005, 7:07pm UTC](https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851 "2005-10-07T19:07:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [October 7, 2005, 7:07pm UTC](https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851/1 "2005-10-07T19:07:20Z")

</div>

Hi all,

I’m trying to write a genric method to open a form in a Dialog.  
Is there a way of finding the width of a named form?

```auto
var v = forms['myform'].width;

```

Doesn’t seem to work.

Or will I have to pass the width as a parameter to my method?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [October 7, 2005, 7:30pm UTC](https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851/2 "2005-10-07T19:30:43Z")

</div>

Hi Christian,

If you just want to use the current width of the form you open then just use -1 as width parameter in the ShowFormInDialog.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![grahamg](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@grahamg](https://forum.servoy.com/u/grahamg)\
**Post date:** [October 7, 2005, 8:52pm UTC](https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851/3 "2005-10-07T20:52:01Z")

</div>

Just to expand Roberts answer you can use four -1’s and Servoy will automatically centre the Form in Dialogue on the screen and set both width and height.

> application.showFormInDialog( form, -1, -1, -1, -1, [dialog\_title], [resizable], [showTextToolbar], [closeAllOnCloseButton])

Graham Greensall  
Worxinfo Ltd

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [October 7, 2005, 9:23pm UTC](https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851/4 "2005-10-07T21:23:59Z")

</div>

Thanks Graham ![:)]( "Smile")

One thing with the height parameter though.  
When you have a listview, and I guess also with the table view, is that you might want to set the height then or you get unexpected results.

I.e. a very small (as in height) window.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [October 8, 2005, 6:08am UTC](https://forum.servoy.com/t/possible-to-get-the-width-of-a-form-in-javascript/4851/5 "2005-10-08T06:08:02Z")

</div>

> ROCLASI and Graham:  
> -1

I had a feeling there would be a really easy way to do this 🙂

Thanks!
