INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Hide/Unhide div using Radio button onClick

Hide/Unhide div using Radio button onClick

(OP)
I've been trying this for days. JavaScript isn't even firing. Any Suggestions?? I'm using it with Coldfusion.

<script language="JavaScript" type="text/javascript">
function hide(divToHide) {
var me = document.getElementByID(divToHide);
if (me.style.display == "none"){
me.style.display = "block";
} else {
me.style.display = "none";
}
}
</script>


<div class = "col-md-12">
<h4>
<label class="radio-inline">
<input type="radio" value=1 name="decision" class="grey" onClick="hide('hideThis');">
<span style="color:red">Reject</span></label>
<label class="radio-inline">
<input type="radio" value=2 name="decision" class="grey" onClick="hide('hideThis');">
<span style="color:green">Approve</span></label>
</h4>
</div>


<div id="hideThis" style="display:none;">
<br>
<button class = "btn btn-blue btn-block" type = "submitAssign" name ="submitAssign" id = "submitAssign">
Assign <i class = "fa fa-arrow-circle-right" ></i>
</button>
</div>

RE: Hide/Unhide div using Radio button onClick

Javascript is case sensitive. getElementById is different to getElementByID.

This should have popped up an error in the Js console of whatever browser you are using. Something like: Uncaught TypeError: document.getElementByID is not a function

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Hide/Unhide div using Radio button onClick

(OP)
Still not working. No errors! Works in the Tryit Editor on the w3schools website. Just can't get it to work in my ColdFusion page.

RE: Hide/Unhide div using Radio button onClick

hide('hideThis')


should be hide(this.id)

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Hide/Unhide div using Radio button onClick

(OP)
I found the issue after some removing and added back sections and pieces of code around the Radio buttons. The culprit was the class="grey" in <input type="radio" value=1 name="decision" class="grey" onClick="hide('hideThis');"> It was the onClick event that wasn't working because of that piece of code, the JavaScript was working fine. Works like a charm now.

Thanks to all anyway for the responses.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close