Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Show or hide form fields based on cfselect selection

$
0
0

Hi,

 

I'm using ColdFusion 9 and

 

I want to show/hide a form field type=checkbox if an assigned value is selected in a dropdown list, but it doesn't work.

I use a javascript function.

My question is: Are there better possibilities with ColdFusion to do this or is Javascript the best solution???

 

 

Here is my code:

 

<script type="text/javascript">

    function show(){

        var select = document.getElementById('dropdownlist').selectedIndex;      

        if(select == 1) document.getElementById('area').style.display = "block";

        else document.getElementById('area').style.display = "none";       

    }

</script>

 

 

....

<cfquery name="select_list">

select * from table

</cfquery>

 

<cfform name ="form">

 

<cfselect name="dropdownlist" onChange="show();">

    <option value="0">please select</option>

    <cfloop query="select_select_list">

     <option value="#select_select_list.id#">#select_list.name#</option>

    </cfloop>       

    </cfselect>

 

 

<div id="area" style="display:none">

         <cfloop query="select_list" > 

         <tr style="display:none">

      <td>    

           <cfinput name="gsu"  type="checkbox"  value="#select_list.id#"> #select_list.name#

          </td>

     </tr>

         </cfloop> 

     </div>

</cfform>

 

 

Thank you and best regards!

 

Claudia


Viewing all articles
Browse latest Browse all 5794

Trending Articles