Forum Moderators: open

Message Too Old, No Replies

If form button is selected div should be hidden

JavaScript with some CSS

         

SilverLining

2:47 pm on Feb 20, 2006 (gmt 0)

10+ Year Member



I have a form with a default radio button selected.

If any other radio buttons are selected it displays another div with two radio buttons, correctly.

Problem is when the first radio button is selected again the div needs to disappear.

The only way I can get this to work is if I have an onload function which hides the div. But I have tried calling this function onclick="()". The first radio button already has three onclick functions associated with it.

This is the function

<script>
/* Hide Div */
function hidediv(){
document.getElementById("hideme").style.display="none";
}

</script>

The solutions would be something like hiding the div (id=hideme) when radio button is selected.

I am not looking for the usual show/hide divs code. This is part of a huge JS file and I dont really want to make it much more complicated. Hope this makes sense. Thanks in advance

SilverLining

3:41 pm on Feb 20, 2006 (gmt 0)

10+ Year Member



Sorted. Here's the code, in case anyone needs a solution for this in future:

<script type="text/JavaScript">
function show(id)
{
if (document.getElementById(id).style.display == 'none')
{
document.getElementById(id).style.display = '';
}
}
function hide(id)
{
document.getElementById(id).style.display = 'none';
}
</script>

and then use onfocus="hide('id');return true;" and onfocus="show('id');return true;".

Set div to display:none