Skip to main content
Known Participant
February 22, 2010
Question

need to fix this

  • February 22, 2010
  • 1 reply
  • 441 views

Hi Below is the code in which we have two div tags and when i select one option fron radio button i need to show one block and when i select other option i need to show other block of code and hide the other , but i amnot able to do that , will any one help me in this

thanks

<script language="JavaScript" type="text/javascript">
       function showHide(el_id) {
        if (document.getElementById(el_id).style.display == "none"){
            document.getElementById(el_id).style.display = "block";
            }
        else if(document.getElementById(el_id).style.display == "block"){
            document.getElementById(el_id).style.display = "none";
        }
    }
</script>
<input type="radio" name="myName" value="0" onClick="showHide('showHideDiv');">select multiple divisions
<input type="radio" name="myName" value="1" onClick="showHide('showHideDiv');" checked="true">No Multiple Selections


<div id="showHideDiv" style="display:none;">

<table>   
         <tr>
         <td><strong>Division:</strong></td>        
         <td>   
         <select  name="div_no"  multiple="true" size="5"  >
         <cfoutput query="qryDivisions">
         <option value="div_no">#div_no# -  #div_desc#</option>       
         </cfoutput>       
         </select></td></tr>
     </table>
</div>


<div id="showHideDiv" style="display:none;">

    <table>   
        <tr>
        <td><strong>Division:</strong></td>       
        <td>   
        <select  name="div_no"  multiple="true" size="5"  >
        <cfoutput query="qryDivisions">
        <option value="div_no">#div_no# - #div_desc#</option>       
        </cfoutput>       
        </select></td></tr>
    </table>
</div>

This topic has been closed for replies.

1 reply

existdissolve
Inspiring
February 22, 2010

Hey kirannaga--

You've got a couple issues that I see right off the bat. First, both of your divs have exactly the same ID. Besides producing improperly formed XHTML, you've left no way to easily differentiate between the two divs, especially when you are passing their ID's as arguments to your function.

So you'll definitely want to start by giving unique names to each of your divs.  Then, in your function, you can expand the logic a bit to dyanamically evaluate which div needs to be hidden, and which needs to be shown.

cfnewAuthor
Known Participant
March 1, 2010

hi thanks for your reply is there any way how to do this , i am new to development will you plaese provide me some answer.

Thanks.