Show or hide form fields based on cfselect selection

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

Okay, thank you for your answer.
I changed the javascript function and replaced the <div> with the <table> tag. Then it works.
Here is an extract of my code:
<script type="text/javascript">
    function show(){
        var select = document.getElementById('dropdownlist'); 
        var strUser = select.options[select.selectedIndex].value;    
        if(strUser== 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">
<table id="area" style="display:none">
         <cfloop query="select_list" > 
         <tr">
      <td>    
           <cfinput name="gsu"  type="checkbox"  value="#select_list.id#"> #select_list.name#
          </td>
     </tr>
         </cfloop> 
     </table>
</cfform>

Similar Messages

  • Hide form field based on name that contains certain characters

    I think this is an easy one.
    We're looking for help with a script that will hide all instances of text fields that contain a certain value. We have a function running that applies to the same text fields, however, each text field had to be tagged with a number at the end. Also running with this is a custom save button that flattens the page and hides certain elements before saving out. The hide function works pretty straightforward with "this.getField… = display.hidden;". The issue is that we don't want to repeat this for every single instance of the text fields that share the same name.
    We need it look for every text box that has a similar title so for instance if we had multiple fields like this…  "my-text-field-01", "my-text-field-02" and "my-text-field-03" we want the script to look for the name "my-text-field" and hide all instances of that.
    Hope this makes sense, sorry, our programming skills are still amateur. Thanks in advance for any help.

    You can do that if you use a heirarchical naming convention. So instead use something like: my-text-field.1, my-text-field.2, etc.
    You can then hide them all like:
    // Hide all of the "my-text-field" fields
    getField("my-text-field").display = display.hidden;

  • Show/Hide JSF field based on SelectOnceChoice using Model Driven List

    Hello All,
    I have a use case where I want to show or hide fields based on values populated in SelectOneChoice. I have View master and View Lookup, master has a field named product which displayed selectiononechoice of product name built using lookup view as accessor. I am storing id of lookup type inside product column. Based on a product name say "abc" I want to hide subsequent fields. Can anyone please tell me how to implement this?
    I am using ADF 11g version 11.1.2.
    Thanks,
    Dipal

    If I understand you correctly, you are trying to show/hide subsequent fields based on the value selected from a selectonechoice?
    Did you try using partial triggers and EL for setting the rendered attribute on subsequent fields and setting autosubmit to true on selectonechoice?
    Kristjan

  • Showing/Hiding certain fields based on Radioset selection

    Hello all,
    I'm like to know whether it is possible to Show/Hide certain fields using a RadioSet selection as it is done in Forms in ADF UIX. Kindly go through this post.
    Showing/Hiding certain fields based on Radio Group selection
    kindly help me out on this.
    Thanks & Regards,
    Arun.V

    Hi Arun,
    Here is what I do with my checkboxes, but I think that the radiobutton will do the same:
    <af:selectBooleanCheckbox text="selectBooleanCheckbox 1"
                          label="Label 1"
                          binding="#{backing_page1.selectBooleanCheckbox1}"
                          id="selectBooleanCheckbox1"
                          autoSubmit="true"
                          immediate="true"/>
    <af:inputText label="Label 1" binding="#{backing_page1.inputText1}"
                          id="inputText1"
                          disabled="#{!backing_page1.selectBooleanCheckbox1.selected}"
                          partialTriggers="selectBooleanCheckbox1"
                          value="#{backing_page1.selectBooleanCheckbox1.selected}"/>

  • Interactive form that auto selects input fields based on initial selection

    i want to create a form that based on initial selections, automatically highlights "required" input fields.
    i.e.  if i create an item on the form called "promotion", when this item is "checked", all the fields that are required will automatically light up, and the person completing the form cannot exit, save, and submit the form until all related fields are filled in.
    is this possible using adobe products?  i have cs5 (with dreamweaver, indesign, etc.)
    can anyone point me toward any documentation that will show me how to do this?

    This forum is for Adobe FormsCentral (formscentral.adobe.com) which is a service that allows you to create, collect and analyze data using an online web form. You should ask general HTML form related questions in the Dreamweaver forums:http://forums.adobe.com/community/dreamweaver/dreamweaver_general
    I'll move your post to that forum so you don't need to retype it. They can help you out...
    Randy

  • Show or Hide empty table based on If condition

    I want to show or hide empty table based on condition. The table will be empty with 5 rows,2 cols and should display if <?Rout_Information1_id1?> is blank or null or when XML field is not present. Actually the JDEdwards report will generate XML file. In the XML file if <?Rout_Information1_id1?> is present it will have definitely value like 'PULL' or 'Cut' otherwise sometimes XML field itself will not be present. Need to display the empty table when the <?Rout_Information1_id1?> is not present. I am trying to do as below but the table is not displayed. Can someone tell me how to resolve this.
    <?if:Rout_Information1_id1=' '?>
    5 rows,2 cols table
    <?end if?>
    Thanks,
    Vijay Vattiprolu

    Ok. I used the below syntax from other post and it resolved displaying empty table issue.
    <?if:not(XML_TAG_NAME)?>
    <?end if?>
    Thanks,
    Vijay

  • Is there a way to hide some reports based on the selected values in prompt.

    Hi Experts,
    Is there a way to hide some reports based on the selected values in prompt.
    For ex. if a year is selected in the prompt then the report should display year wise report.
    If a year and half year both are selected in the drop down from prompt section then 2 reports should come.. One for year wise and another for half year wise.Kindly look into this.
    Regards
    Ashish

    Hi,
    Use presentation values in prompts for year,half,qtr and month.Example- For year-y is presentation variable in the same way for halfyear-h,qtr-q and month-m.
    create four intermediate reports.Example-Report r1 with only year column,r2 with only halfyear column,r3 with qtr column and r4 with month column.
    Make column in each report(r1,r2,r3,r4) is equal to their presentation variables(y,h,q,m).
    Use four sections.
    Section1-Place report that should come when only year.
    section2-Place report that should come for year and halfyear.
    Section3-Place report that should come for year,halfyear and qtr.
    Section4-Place report that should come for year,halfyear,qtr and month.
    Apply guided navigation for each section selecting guided navigation-
    For section1-
    properties->Guided navigation->check this Reference Source Request(Yes)->select report r1(year)->check this Show Section(if request returns row)
    In the same way do for remaining section2(select r2),section3(select r3) and section4(select r4)
    Thanks,
    Srikanth
    http://bintelligencegroup.wordpress.com/

  • Dynamically enable a field based on a selected table row

    Hi everyone.
    I'm getting really confused right now, please show me the right way. My approach may be, and probably is, wrong since I am self learning this and all I have is an ASP.NET background.
    I have a page with a table in it. I've created a DataControl for a collection I've made and mapped it to the table. I added a column that shows an "edit" button. On it's click, I open a popup that shows the selected row's data. Naviguation controls are also present on the popup.
    This is working fine.
    My problem comes in the popup. Each row has multiples fields. These fields, shown on the popup, need to dynamically be enable/disable. To toggle those field, the only way I can see right now is to have a function that takes into parameter the rowId and the fieldName. Based on those two fields, I can get the necessary information to know if I need to enable or disable the control.
    What I was aiming for, but then again I totally failed, was to have that function called on the "enabled" EL Expression, returning a Boolean.
    Now that this has been said, can someone guide my on how to dynamically enable/disable each field based on the selected row.
    Thanks !

    Above +
    why don't you create a bean method that returns a Boolean ans through EL Expression Builder select the method to this property.
    btw .. on which components are you setting this?
    Also,
    If there is business logic that prohibits to update this object unless that is met.. you can also do it as..
    In EOImpl .. override isAttributeUpdateable(int i) method eg:
    @Override
    public boolean isAttributeUpdateable(int i) {
    if(i == this.ENAME && "KING".equalsIgnoreCase(this.getEname())){
    return true;
    }else
    return super.isAttributeUpdateable(i);
    and then in UI for the component say
    ReadOnly = #{bindings.Ename.updateable}
    Or, In UI
    disable = #{ bindings.Ename.attributeValue == 'KING' & bindings.Mrg.attributeValue == null ? true : false}
    adf does provides many ways to do it ..
    Cheers, Amit

  • Auto populate fields based on dropdown selection

    New to forms and needing some insight
    Is there a way to auto populate a series of fields based on the selection of a dropdown box
    for instance;
    chosing a customer's name from a dropdown box would auto populate the address, city,state zip etc...

    Yes, but not easy and you do not want to have a large number of items.
    Programming List and Combo fields in Acrobat and LiveCycle forms - Part 1 by Thom Parker

  • SSRS 2008 - hide chart lines based on parameter selected

    How to control visibility of chart lines based on Params selected by user?
    By default, my report display last 3 years worth of data (including current) with Month on the x axis and Counts on the y axis. I have two Boolean parameters:
    TwoYrs? T/F
    ThreeYrs? T/F
    if False is selected for TwoYr and ThreeYr parameters then I want to hide chart lines corresponding to last year and the year before.
    What I've tried: Created 3 Series groups with filters. eg. YearSeries1 to return only current year data and applying an expression to display it if params TwoYrs and ThreeYrs = False. and so on for YearSeries2 to return current + last
    years data if param TwoYrs is True and ThreeYrs = False.  But I don't see where to add expression to control the display of the individual series groups.  I am open to any way of doing this, but this seemed most logical.

    Hi Ok-Hee,
    In your Source Query just need to filter the series data based on the Parameters.
    I have written sample query below:-
    select * from
    select 1 monthnumber , 'Jan' MonthName, 2013 year,100 amount
    union
    select 1 monthnumber , 'Jan' MonthName, 2014 year ,200 amount
    union
    select 1 monthnumber , 'Jan' MonthName, 2015 year , 300 amount
    union
    select 2 monthnumber , 'Feb' MonthName, 2013 year, 300 amount
    union
    select 2 monthnumber , 'Feb' MonthName, 2014 year, 350 amount
    union
    select 2 monthnumber , 'Feb' MonthName, 2015 year,200 amount
    union
    select 3 monthnumber , 'Mar' MonthName, 2013 year, 380 amount
    union
    select 3 monthnumber , 'Mar' MonthName, 2014 year, 100 amount
    union
    select 3 monthnumber , 'Mar' MonthName, 2015 year, 500 amount
    )t
    where year in (
    select distinct FilterYear from
    select case when @TwoYrs=1 then year(getdate())-1 else year(getdate()) end FilterYear
    union
    select case when @TwoYrs=1 and @ThreeYrs =1 then year(getdate())-2 else year(getdate()) end FilterYear
    union
    select year(getdate()) FilterYear
    ) t
    I have created one post in my blog , you can check the result.
    https://msbitips.wordpress.com/2015/03/12/ssrs-2008-hide-chart-lines-based-on-parameter-selected/
    Thanks
    Prasad

  • SSRS Matrix report to show or hide year column based on parameter value "Date" selected.

    Hey experts!
    I have a requirement an ssrs matrix report should display columns (year/s) based on parameter value (date/s). 
    My Dataset fileds are: Product, Year_name, Month_name, Date
    Currently my report output looks like this-
    Param Date: 2013-08-01 00:00:0.000
    Product +Calender2011      +Calender2012     -Calender 2013........                        +Calender2014
                             Total
                      Total Jan13  Feb 13  Mar13..  Dec13   Total           Total
    Abc                      100
                        220
    10      20         30.......  20       250              400
    Xyz 110
    200 50      80         40.......  30       450              600
    My requirement:  if I'm selecting Date parameter value as '2013-xx-xx' I should only able to see Year column 'Calender2013' and rest of the years should hide. Similarly If I'm selecting Date parameter value as '2014-xx-xx' I should only able to
    see Year column 'Calender2014' .
    Appreciate your kindly help. 
    Afan

    Hi Afan,
    According to your description, you want to only show the selected year on your report, right?
    In this case, you need to get the year from the date parameter using the expression below
    =Year(Parameters!Date.Value)
    And then use the expression below to get the year from Year_Name field.
    =Right(Fields!Year_Name.Value,4)
    Then add a filter to the dataset to filter the data like below
    Expression:=Year(Parameters!Date.Value)
    Operator:=
    Value:=Right(Fields!Year_Name.Value,4)
    Reference
    http://msdn.microsoft.com/en-IN/library/dd255287.aspx
    If you have any questions, please feel free to ask.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to make a button show AND hide a field?

    In an interactive form (with Adobe Acrobat X Pro), how can I purpose one button to:
    1.) Show a field when clicked the first time
    2.) Hide a field when clicked a second time
    I seem to only be able to make a button do one or the other, but not both with the same button. Maybe an easier way to say this is I want to be able to have one button turn a field "on" and "off".
    Any help would be GREATLY appreciated. Thanks! 

    Use this code:
    var f = this.getField("OtherFieldName");
    if (f.display==display.visible) f.display = display.hidden;
    else f.display=display.visible;

  • How to Hide Form Field If the data null

    Hi All,
    I have an issue in the RTF, i am working in XMLP 5.6.2 Desktop Edition. I am developing template for Dunning Letter report. I have four fields in the footer like collector name,mail id, tele number and then fax. Here some collectors may not having fax and mail id since these fields are opition in the DFF. So I want to hide the form fields with the labels also if the collectors dont have mail id and fax nos. Now i am getting blank space for the collector who dont have mail id and fax nos. I dont knw what logic that need to apply over here.
    I have the form fields in the template like ....
    <?COLLECTOR_NAME?>
    <?COLLECTOR_MAIL_ID?>
    Tel. <?COLLECTOR_TELE?>
    Fax. <?COLLECTOR_FAX?>
    Please advice me to close this issue.
    Thanks in Advance
    Prabu

    Hi,
    This tag is working if the fax value is not in the xml code. But i am getting blank space
    Cfx, In my report if mail id and fax is not avaliable then it displays like...
    HENRY MICH (Collector name)
    (Collector mail id)
    432-627-9393 (Collector phone)
    (Collector fax)
    I want to display the in my report like
    HENRY MICH
    432-627-9393
    I want to remove the blank space for the mail id and fax if the value is not there in the report.
    Please advice me to resolve this...
    with regards
    prabu

  • Hide Form Field

    I have a form that captures data, the user can sign up as a
    couple or single. On a couple the have to put in 2 names on a
    single only one. I would like the second name field only available
    if they select couple from a drop down or radio button.
    I use ASP/VBScript. How can I accomplish this, is there a
    plug in, or code example I can use, maybe AJAX.
    Thanks

    Check out this JavaScript:
    http://javascript.internet.com/forms/field-show-2.html
    Walt
    "Ken Pollard" <[email protected]> wrote in
    message
    news:gch0uk$6r4$[email protected]..
    >I have a form that captures data, the user can sign up as
    a couple or
    >single.
    > On a couple the have to put in 2 names on a single only
    one. I would like
    > the
    > second name field only available if they select couple
    from a drop down or
    > radio button.
    >
    > I use ASP/VBScript. How can I accomplish this, is there
    a plug in, or code
    > example I can use, maybe AJAX.
    >
    > Thanks
    >

  • How to hide form fields in OIM?

    Hi,
    i want to customize OIM so, that a user see only the form field "create user".
    The form field for Role, Organization and Autorization Policies" should be disabled/hided for designated user.
    Is it possible to manage this over autorization policies?

    The set of links for users, roles, organizations and authorization policies are defined in the web application. Authorization policies only define which ones are accessible or greyed out. Selection links are always shown, with authorization policies only defining which objects are retrieved by the search.
    If you want to remove the links altogether you will need to modify the web application oim.ear.
    Edited by: duncandb on Jun 15, 2012 6:15 AM

Maybe you are looking for