Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 ASP.NET C#4.0
i am trying to Check On RadioButtonList, if YEs then textbox is enable and if radiobuttonlist is no then textbox is disable.. i tried but after check and un-check then my web form is refreshing that i don't want
Posted 16-Apr-13 20:27pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This may help you....
 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Hide OR Show DIV</title>
    <style type="text/css">
        .box
        {
            display: block;
            border-radius: 8px;
            height: 150px;
            width: 300px;
            border: 2px solid lightgray;
            margin: 0 auto;
            padding: 3px;
            position: fixed;
            cursor: move;
        }
    </style>
 
    <script type="text/javascript">
 
        function hideorshow(s) {
            debugger;
            if (s == 'Show') {
                //            var rdbs = document.getElementById("rdbShow").checked;
                //            var rdbh = document.getElementById("rdbHide").checked;

                //            if (rdbs == true) {
                document.getElementById('d1').style.display = "block";
                document.getElementById('rdbHide').checked = false;
            }
            if (s == 'Hide') {
                document.getElementById('d1').style.display = "none";
                document.getElementById('rdbShow').checked = false;
            }
        }
 
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <p>
            <input type="radio" onclick="hideorshow('Show');" id="rdbShow" value="Show" />
            <input type="radio" onclick="hideorshow('Hide');" id="rdbHide" value="Hide" />
            <div align="center" style="display: none;" class="box" id="d1">
                <h1>
                    Hello, Wel Come To Code Project</h1>
            </div>
    </div>
    </form>
</body>
</html>
  Permalink  
Comments
Member61 at 17-Apr-13 1:39am
   
Replace div with your textboxes....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

you have to do this only
 
This is your javascript function
 
<script type="text/javascript">
 
    function hideorshow(s) {
        debugger;
        if (s == 'Show') {
            //            var rdbs = document.getElementById("rdbShow").checked;
            //            var rdbh = document.getElementById("rdbHide").checked;

            //            if (rdbs == true) {
            document.getElementById('d1').style.display = "block";
            document.getElementById('rdbHide').checked = false;
        }
        if (s == 'Hide') {
            document.getElementById('d1').style.display = "none";
            document.getElementById('rdbShow').checked = false;
        }
return false;
    }
 
</script>
 

see i added " return false; at the end of the function.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

you have to do this only
 
This is your javascript function
 
<script type="text/javascript">
 
    function hideorshow(s) {
        debugger;
        if (s == 'Show') {
            //            var rdbs = document.getElementById("rdbShow").checked;
            //            var rdbh = document.getElementById("rdbHide").checked;

            //            if (rdbs == true) {
            document.getElementById('d1').style.display = "block";
            document.getElementById('rdbHide').checked = false;
        }
        if (s == 'Hide') {
            document.getElementById('d1').style.display = "none";
            document.getElementById('rdbShow').checked = false;
        }
return false;
    }
 
</script>
 

see i added " return false; at the end of the function.
and
 
     <input type="radio" onclick="return hideorshow('Show');" id="rdbShow" value="Show" />
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 410
1 Jochen Arndt 200
2 Richard MacCutchan 135
3 DamithSL 105
4 PIEBALDconsult 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100