Link to home
Start Free TrialLog in
Avatar of Fraser_Admin
Fraser_AdminFlag for Canada

asked on

Javascript hide button

I need to know how to make an input button hidden from javascript.  I'm finding my input button by using the eval function

var obj = eval(Type + ID);

I then need to be able to say something like

if (Type == 'Sub')
{
   obj.visibility = 'hidden';
}
else
//make it visible

But this doesn't seem to work.

ASKER CERTIFIED SOLUTION
Avatar of bruno
bruno
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of travisjhall
travisjhall

Specs are your friends. Check http://www.w3.org/TR/REC-CSS2/ to find out your CSS details.

Brunobear is correct. "obj.style.visibility = 'hidden';" will do the job as long as you want the button to still affect layout. (That is, if you want an empty space where the button would be if it was visible.)

If you don't want the empty space, "obj.style.display = 'none';" is what you are after.
and obj irepresents the name of your button, b_name in this example:

<input type="submit" name="b_name" value="OK" >