How to set width of text input to physical text width

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • johkar

    How to set width of text input to physical text width

    I have a grid. When the focus is put on a cell an input is created with the
    value being the cell's text. I would like to size the input to the physical
    width of the text. Ideas?

    John

    function editCell (cell) {

    if (document.getEl ementById) {
    cell.normalize( );
    var input = document.create Element('INPUT' );
    input.setAttrib ute('value', cell.firstChild .nodeValue);
    input.setAttrib ute('size', cell.firstChild .nodeValue.leng th); //RATHER
    THAN SET THE SIZE, I WOULD PREFER TO SET STYLE WIDTH

    input.onblur = function (evt) { setCell(this.pa rentNode,this.v alue); };
    input.onclick = function (evt) {
    evt.cancelBubbl e = true;
    if (evt.stopPropag ation)
    evt.stopPropaga tion();
    };

    cell.replaceChi ld(input, cell.firstChild );

    input.focus();
    input.select();
    }

    }


  • johkar

    #2
    Re: How to set width of text input to physical text width

    Doh! I just set the input widths in CSS to 100% and it does what I want.

    John

    "johkar" <nosendjunk@lin k.net> wrote in message
    news:hLP6b.3063 $Yt.1743@newsre ad4.news.pas.ea rthlink.net...[color=blue]
    > I have a grid. When the focus is put on a cell an input is created with[/color]
    the[color=blue]
    > value being the cell's text. I would like to size the input to the[/color]
    physical[color=blue]
    > width of the text. Ideas?
    >
    > John
    >
    > function editCell (cell) {
    >
    > if (document.getEl ementById) {
    > cell.normalize( );
    > var input = document.create Element('INPUT' );
    > input.setAttrib ute('value', cell.firstChild .nodeValue);
    > input.setAttrib ute('size', cell.firstChild .nodeValue.leng th);[/color]
    //RATHER[color=blue]
    > THAN SET THE SIZE, I WOULD PREFER TO SET STYLE WIDTH
    >
    > input.onblur = function (evt) {[/color]
    setCell(this.pa rentNode,this.v alue); };[color=blue]
    > input.onclick = function (evt) {
    > evt.cancelBubbl e = true;
    > if (evt.stopPropag ation)
    > evt.stopPropaga tion();
    > };
    >
    > cell.replaceChi ld(input, cell.firstChild );
    >
    > input.focus();
    > input.select();
    > }
    >
    > }
    >
    >[/color]


    Comment

    Working...