Link to home
Start Free TrialLog in
Avatar of onaled777
onaled777Flag for United States of America

asked on

Hiding and showing divs using javascript

The attached code snippet gives my attempt to hide and show divs using javascript.  Right now I am not getting any response from any of the radio button clicks and just need some help understanding why.



THE JAVASCRIPT FUNCTION:
 
function show_div(div_id) {
    // hide all the divs
    document.getElementById('url').style.display = 'none';
    document.getElementById('content').style.display = 'none';
 
    // show the requested div
    document.getElementById(div_id).style.display = 'block';
}
 
 
 
THE CALL TO THE JAVASCRIPT FUNCTION
 
		<tr>
			<td align="right">Content Type:
			</td>
			<td>
				Remote: <input type="radio" name="CreativeContentType" value="Remote" <cfif #CreativeContent.CreativeContentType# eq 'Remote'>checked</cfif> onclick="show_div('url'); return false;">
				Hosted: <input type="radio" name="CreativeContentType" value="Hosted" <cfif #CreativeContent.CreativeContentType# eq 'Hosted'>checked</cfif> onclick="show_div('content'); return false;">
			</td>
		</tr>
 
 
 
 
 
THE DEFINED DIVS
 
		<div style="display: none;" id="url">
			<tr>
				<td nowrap align="right" valign="top">URL: 
				
				</td>
				<td nowrap>
					<INPUT TYPE="text" SIZE=80 NAME="RemoteContentUrl" ID="RemoteContentUrl" class="Forminput" value="#CreativeContent.RemoteContentUrl#">&nbsp;
					<input name="Content" type="hidden" value="">
				</td>
			</tr>
		</div>
		<div style="display: none;" id="content">
			<tr>
				<td align="right">Content:
				</td>
	
				<td><input name="RemoteContentUrl" type="hidden" value="">
					<textarea name="Content" id="Content" cols="100" rows="12" wrap="soft" 
						class="OptsFormData">#CreativeContent.Content#</textarea>
				</td>
			</tr> 
		</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna 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 onaled777

ASKER

This worked perfectly thank you.