radio button visible=true using javascript

Currently I have this tag:

<asp:CheckBox runat="server" Visible="false" ID="domain1nego" Text="I would like to consider negotiations with current owner." />


What javascript code would I need in order to make domain1nego.Visible="True"


I tried using:

<script language="javascript" type="text/javascript">
    function showDomainNego1() {
        document.getElementById('domain1nego').style.visibility = 'visible';
        return false;
    }
</script>

but it didn't work.


Thanks ahead of time!!
igotstehsolutionAsked:
Who is Participating?
 
leakim971PluritechnicianCommented:
Try this :

document.getElementById('domain1nego').parentNode.setAttribute("style", "display:block");
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication13._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <asp:CheckBox runat="server" style="display:none" ID="domain1nego" Text="I would like to consider negotiations with current owner." />
    <script language="javascript" type="text/javascript">
        document.getElementById('domain1nego').parentNode.setAttribute("style", "display:block");
    </script>
    </form>
</body>
</html>

Open in new window

0
 
leakim971PluritechnicianCommented:
Try :
<script language="javascript" type="text/javascript">
    function showDomainNego1() {
        document.getElementById('domain1nego').style.visibility = true;
        return false;
    }
</script>

Open in new window

0
 
leakim971PluritechnicianCommented:
This one too :


<script language="javascript" type="text/javascript">
    function showDomainNego1() {
        document.getElementById('<%= domain1nego.ClientID %>').style.visibility = true;
        return false;
    }
</script>

Open in new window

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
igotstehsolutionAuthor Commented:
I tried both. Unfortunately neither worked.

Any other suggestions?
0
 
leakim971PluritechnicianCommented:
Use :



because Visible="false" is interpreted on the server side and the checkbox is not in the page at the loading so you can't play with Javascript.

To display it, use : document.getElementById('domain1nego').setAttribute("display", "block");
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication13._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:CheckBox runat="server" display="hidden" ID="domain1nego" Text="I would like to consider negotiations with current owner." />
    <script language="javascript" type="text/javascript">
        document.getElementById('domain1nego').setAttribute("display", "block");
    </script>
    </form>
</body>
</html>

Open in new window

0
 
igotstehsolutionAuthor Commented:
<asp:CheckBox runat="server" display="hidden" ID="domain1nego" Text="I would like to consider negotiations with current owner." />

is still visible. so I tried style="display:none" and that made it invisible yet your setattribute script didn't work.


I tried making getElementById('<%= domain1nego.ClientID %>') aswell but that also didn't work.
0
 
leakim971PluritechnicianCommented:
Sorry : display="none"
0
 
leakim971PluritechnicianCommented:
not : display="hidden"
0
 
igotstehsolutionAuthor Commented:
display="none" still doesn't work. the checkbox is visible.
0
 
leakim971PluritechnicianCommented:
sorry again the right one is: style="display:none"
<asp:CheckBox runat="server" style="display:none" ID="domain1nego" Text="I would like to consider negotiations with current owner." />

Open in new window

0
 
leakim971PluritechnicianCommented:
and :


document.getElementById('domain1nego').setAttribute("style", "display:block");

Open in new window

0
 
igotstehsolutionAuthor Commented:
Now its hidden but javascript isn't working to make it visible again.
0
 
igotstehsolutionAuthor Commented:
works :)

tytyty
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.