hiding button

Posted by Vineeth1311 under ASP.NET on 10/3/2007 | Views : 1861 | Status : [Member] | Replies : 4
hi i need code to hide some fields when i select checkbox or radio button




Responses

Posted by: Bubbly on: 2/22/2010 [Member] Bronze

Up
0
Down
Hello,

You can simply write
if(checkbox1.checked)

{
btntest.visible = false;
}


++
Thanks & Regards,
Deepika

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 11/15/2011 [Member] Starter | Points: 25

Up
0
Down
buttonid.visible=false;


ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 10/3/2007 [Administrator] HonoraryPlatinum

Up
0
Down
Hi Vineeth,

I am going to give you an example of how to do it.

Below is the code of the form I am going to write
<table width="390">

<tr>
<th colspan="2">Radio Button demonstration</th>
</tr>
<tr>
<td>
<input type="radio" checked="checked" name="radioSel" id="radio1" onclick="ShowHideBasedonRadio('divFn')" />Show First Name
</td>
<td>
<div id="divFn" style="display:;">
<input type="text" id="txtFName" value="First Name" />
</div>
</td>
</tr>
<tr>
<td><input type="radio" name="radioSel" id="radio2" onclick="ShowHideBasedonRadio('divLn')" />Show Last Name </td>
<td>
<div id="divLn" style="display:none;">
<input type="text" id="Text1" value="Last Name" />
</div>
</td>
</tr>
</table>

<table width="390">
<tr>
<th colspan="2">Check Box demonstration</th>
</tr>
<tr>
<td>
<input type="checkbox" id="check1" onclick="ShowHideBasedonCheckbox(this, 'div1')" />Show First Name
</td>
<td>
<div id="div1" style="display:none;">
<input type="text" id="Text2" value="First Name" />
</div>
</td>
</tr>
<tr>
<td><input type="checkbox" id="check2" onclick="ShowHideBasedonCheckbox(this, 'div2')" />Show Last Name </td>
<td>
<div id="div2" style="display:none;">
<input type="text" id="Text3" value="Last Name" />
</div>
</td>
</tr>
</table>


Following is the JavaScript code that will fire after clicking on radion button and checkbox.

<script language="javascript" type="text/javascript">

function ShowHideBasedonRadio(id)
{
if (id == 'divFn')
{
document.getElementById('divFn').style.display = '';
document.getElementById('divLn').style.display = 'none';
}
else
{
document.getElementById('divFn').style.display = 'none';
document.getElementById('divLn').style.display = '';
}

}

function ShowHideBasedonCheckbox(chk, id)
{
chk.checked == true ? document.getElementById(id).style.display = '' : document.getElementById(id).style.display = 'none';

}

</script>


Please let me know if this is what your requirement is. I have attached one demo file also that is the working example of the code.

Regards
 Download source file

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dotnetbuddy on: 11/6/2007 [Member] Starter

Up
0
Down
buttonName.Visisble = false

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response