Link to home
Start Free TrialLog in
Avatar of swedesamurai
swedesamuraiFlag for Germany

asked on

Javascript Automatically click radio button on load if hidden field is Not empty

Hello Experts,
I have a Javascript that evaulates whether a field i full or empty and shows a show hide div by name.  I have been trying to modify it so that a radio button would also be checked at the same time. Does anyone have an ideas of how I could do this  The code snippet below is how the script evaluates field KDKK1 for presence and the shows a division id named pay2.  I would also like it to check a radio button named CC at the same time.  Is this possible.  I start this button in body elemt of the form so that it automatically evaluates the field on load (KDNKK1) is an imported value from PHP.  Any help would greatly be appreciated.  Thanks.
function changeDisplay1()
    {
        var elm = document.getElementById('KDNKK1');
		var vis = ( (elm.value == '') ? 'none' : '');
		
        elm = document.getElementById('pay2');
        if (elm != null)
		    elm.style.display = vis;
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ludofulop
ludofulop

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
SOLUTION
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
SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark 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 swedesamurai

ASKER

Because I have a rock for a brain it takes me a while to undrstand things.  Your help on this was really great.  The basic code from ludofulop was helpful.  The info by Allamz helped me learn, and the final croup de grace was the line of code from mplungian that solved my exact problem.  Thanks Experts you saved me yet again