Link to home
Start Free TrialLog in
Avatar of igotstehsolution
igotstehsolution

asked on

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!!
Avatar of leakim971
leakim971
Flag of Guadeloupe image

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

Open in new window

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

Avatar of igotstehsolution
igotstehsolution

ASKER

I tried both. Unfortunately neither worked.

Any other suggestions?
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

<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.
Sorry : display="none"
not : display="hidden"
display="none" still doesn't work. the checkbox is visible.
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

and :


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

Open in new window

Now its hidden but javascript isn't working to make it visible again.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe 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
works :)

tytyty