Why doesnt the JavaScript close function work


I have written a Javascript Close function, which upon being called closes the DIV name that it has been given.
The function works fine in every page I have used it, but it is not working in the main sing-up page, here:


The function is very simple, it is:

function close(item) {
document.getElementById(item).style.display = ‘none’;

And in above page, it is being called when for example you click on the No choice of the field:
"Do you want to be informed when someone posts a Question that can be Answered by you? "

So when you click on the Yes field, its sister function:

function dispaly_hidden_div(item){
document.getElementById(item).style.display = ‘block’;

correctly opens the DIV, but when you click on the No the Close function is not closing the DIV.

I appreciate your input as to why the Close function is all of a sudden not working?


You don’t need 2 separate functions to show or hide the extra div. You can use just 1 function.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <style type="text/css">
                width: 50%;
            #flds1 {
                width: 50%;
            #divQ1 {
                display: none;
        <form action="" method="post">
            <fieldset id="flds1">
                <div id="radBtnsCont">
                    <label for="rad1">Yes</label><input type="radio" id="rad1" name="rad1[]" value="yes" /><br />
                    <label for="rad2">No</label><input type="radio" id="rad2" name="rad1[]" value="no" />
                    Do you want to be informed when someone posts a Question that can be Answered by you?
            <div id="divQ1">
                Do you want to Answer Questions for Free or for a Fee? 
        <script type="text/javascript">
            var radBtns = document.getElementsByName('rad1[]');
            for(var i=0; i<radBtns.length; i++){
                    document.getElementById('divQ1').style.display=(this.value == 'yes')? 'block' : 'none';


Thanks for this Javascript sample code.

But I really need to stick with JS that we have, so I would appreciate an answer to what the problem
is with the JS in our page that is not all of a sudden closing the DIV.


You have overwritten a native function so the interpreter is refusing to call it. Rename it to something else like closeDiv.


Thanks for the Tip.
That did the Job.

What is strange is that same close() function name works in other pages, but in that sign_up.php page it did not until
I changed to close_div as you had suggested.

But thanX again.