...

View Full Version : Invalid Augment error



bthumber
11-16-2010, 05:45 PM
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");
}

Logic Ali
11-16-2010, 05:48 PM
function DecreaseSize(){
var ta.style.height = Math.max( 0, $get('<%=myTextbox.ClientID %>') );
ta.style.height = (parseInt(ta.style.height) - 23) + "px");
}

Old Pedant
11-16-2010, 08:17 PM
Umm...no...what the hell is this 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.

Old Pedant
11-16-2010, 08:20 PM
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:


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.

glenngv
11-16-2010, 08:38 PM
To apply Logic Ali's logic correctly...

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

bthumber
11-17-2010, 07:17 PM
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";
{
}

Old Pedant
11-17-2010, 10:35 PM
Aside from the alert, you could have done

function DecreaseSize(){
var ta = document.getElementById('<%=myTextbox.ClientID %>');
ta.style.height = Math.max( parseInt(ta.style.height) - 23, 23 ) + "px";
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum