Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Florida
    Posts
    9
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Invalid Augment error

    I have a resized textbox. When the textbox gets resized less that 0px I get an Invalid Augment error. How can I trap that error?

    function DecreaseSize(){
    var ta.style.height = $get('<%=myTextbox.ClientID %>');
    ta.style.height = (parseInt(ta.style.height) - 23) + "px");
    }

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Code:
    function DecreaseSize(){   
       var ta.style.height = Math.max( 0, $get('<%=myTextbox.ClientID %>') );   
       ta.style.height = (parseInt(ta.style.height) - 23) + "px");   
    }

  • Users who have thanked Logic Ali for this post:

    bthumber (11-17-2010)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,166
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Umm...no...what the hell is this code:
    Code:
       var ta.style.height = Math.max( 0, $get('<%=myTextbox.ClientID %>') )
    That's *NOT* a legal JavaScript variable name!

    It's meaningless.

    On top of which, $get("...") will simply return a *REFERENCE* to an object, not the height or anything close.
    Last edited by Old Pedant; 11-16-2010 at 07:25 PM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,166
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Code:
    function DecreaseSize(){
        var ta = $get('<%=myTextbox.ClientID %>');
        ta.style.height = Math.max( parseInt(ta.style.height) - 23, 0 ) + "px";
    }
    Dunno what the point of using $get here is. It will work, but it will do the same thing as, and be SLOWER, than simply:
    Code:
    function DecreaseSize(){
        var ta = document.getElementById('<%=myTextbox.ClientID %>');
        ta.style.height = Math.max( parseInt(ta.style.height) - 23, 0 ) + "px";
    }
    LogicAli had the right idea, using Math.max(), but just applied it wrong.
    Last edited by Old Pedant; 11-16-2010 at 07:23 PM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    bthumber (11-17-2010)

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    To apply Logic Ali's logic correctly...
    Code:
    function DecreaseSize(){ 
       var ta =  $get('<%=myTextbox.ClientID %>');
       var height = Math.max(0, parseInt(ta.style.height)-23);   
       ta.style.height = height + "px";   
    }
    Last edited by glenngv; 11-16-2010 at 07:40 PM. Reason: Ooppss..didn't notice Old Pedant's post

  • Users who have thanked glenngv for this post:

    bthumber (11-17-2010)

  • #6
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Florida
    Posts
    9
    Thanks
    8
    Thanked 0 Times in 0 Posts
    function DecreaseSize(){
    var ta.style.height = $get('<%=myTextbox.ClientID %>');
    ta.style.height = (parseInt(ta.style.height) - 23) + "px");
    }
    Old Pennant, yes your correct. The actual code is:

    var ta = $get('<%=myTextbox.ClientID %>');
    ta.style.height = (parseInt(ta.style.height) - 23) + "px");

    But here is the solution I came up with:

    function DecreaseSize(){
    var ta = $get('<%=myTextbox.ClientID %>');

    if (parseInt(ta.style.height) <= 23){
    Window.alert("textBox will not get any smaller");
    }
    else{
    ta.style.height = (parseInt(ta.style.height) - 23) + "px";
    {
    }

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,166
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Aside from the alert, you could have done
    Code:
    function DecreaseSize(){
        var ta = document.getElementById('<%=myTextbox.ClientID %>');
        ta.style.height = Math.max( parseInt(ta.style.height) - 23, 23 ) + "px";
    }
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •