Show or hide form fields based on the selection of cfselect

Hello

I use ColdFusion 9 and

I want to show/hide a form field type = checkbox if an assigned value is selected from a drop-down list, but it does not work.

I use a javascript function.

My question is: is there the best opportunities with ColdFusion for this or Javascript is the best solution?

Here is my code:

< script type = "text/javascript" >

function show() {}

Select var = 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' >

< name = 'dropdownlist' cfselect 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 = 'space' style = "display: none" >

< cfloop query = "select_list" >

< style tr = "display: none" >

< td >

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

< table >

< /tr >

< / cfloop >

< / div >

< / cfform >

Thank you and best regards!

Claudia

Well, thank you for your response.

I changed the javascript function and replaced the

with thetag. Then it works.

Here is a snippet of my code:

Select * from table

Tags: ColdFusion

Similar Questions

  • How to calculate the sum of two digital form fields based on the selection of the checkbox.

    I have a form in Acrobat Pro who needs a custom calculation. How to calculate the sum of two digital form fields based on a selection of the checkbox. I have three number fields. Field-A and B are simple one or two digits. Field-C is the sum, or the total field. I want to field-C have a control box which, when turned on and off, just gives a. gives the sum of A + B

    _ Field - 2

    _ Field - A 4

    [check] _ _ field - 6 C

    [disabled] _ _ field - 2 C

    Thank you

    The custom field C calculation script could be:

    (function () {
    
        // Get the values of the text fields, as numbers
        var v1 = +getField("A").value;
        var v2 = +getField("B").value;
    
        // Set this field's value based on the state of the check box named "CB"
        if (getField("CB").value !== "Off") {
            event.value = v1 + v2;
        } else {
            event.value = v1;
        }
    
    })();
    

    Replace 'A', 'B', and 'CB' with the real names of the fields.

  • Show or hide form fields based on Department

    Hello world

    I have a large form with many fields on. I have a requirement to show/hide some of these fields, based on the Department of the user code. So a user of a particular Department would see a set of fields over only those relevant to their Department - all non-relevant fields for this Department need to be obscured.

    My first thought was to define the conditional on each field and allows you to search if the field to be displayed by checking a department-field table in the SQL database. But it would mean a blow to the database for each field, that I need to check.

    Can anyone think of a more elegant (and efficient) solution for this? I use Apex 4.2.

    Hello

    Permission to create and assign to the patterns.

    Permission is normally performed only once per session.

    Kind regards

    Jari

  • Auto-fill text box values field based on the selection of the menu drop-down

    Try to fill in address, city, province, zip from text fields based on the selected option in a select form field. The following code works fine in Internet Explorer, but in Chrome or Firefox, after selection, text, the fields are filled with the word "undefined."

    I found a PHP script Jquery here version that would probabably do the trick.
    http://StackOverflow.com/questions/3657127/jQuery-populate-text-input-from-table-based-on-select-Valeur

    Maybe someone has a version of CF. they could share?

    Thanks in advance to anyone who can point me to a solution for this code, or a better way to fulfill my need.

    <!--> destinations with address auto-fill, city, etc.
    < script type = "text/javascript" >
    function selectAddress (list) {}
    take the first element is empty
    If (list.selectedIndex > 0) {}
    var locationID = list.options [list.selectedIndex] .value;
    locationAddress var = list.options [list.selectedIndex] .locationAddress;
    var locationCity = list.options [list.selectedIndex] .locationCity;
    var locationState = list.options [list.selectedIndex] .locationState;
    var locationZip = list.options [list.selectedIndex] .locationZip;
    document.getElementById('locationID').value = locationID;
    document.getElementById('locationAddress').value = locationAddress;
    document.getElementById('locationCity').value = locationCity;
    document.getElementById('locationState').value = locationState;
    document.getElementById('locationZip').value = locationZip;
    }
    }
    < /script >
    < b >
    < td align = 'right' bgcolor = "#FFFFFF" valign = "top" > Destination name < table >
    < td align = "left" bgcolor = "#FFFFFF" valign = "top" >
    < select name = "locationID" onChange = "selectAddress (this)" class = "smallforms" > "
    < option value = "" > SELECT the DESTINATION ››› < / option >
    < cfoutput query = "allLocations" >
    "" < option value = "" #locationName # "locationAddress =" #allLocations.locationAddress # "locationCity =" "#allLocations.locationCity #" locationState = "#allLocations.locationState #" locationZip = "#allLocations.locationZip #" > #locationName # < / option >
    < / cfoutput >
    < / select >

    Others: cfinput name = "destinationNameOther" type = "text" class = "smallforms" size = "75" >
    < br / >
    < input id = "locationID" name = "locationID" type = "hidden" > < br >

    Address: < input class = "smallforms" id = "locationAddress" name = "locationAddress" type = "text" size = "30" >
    City: < input class = "smallforms" id = "locationCity" name = "locationCity" type = "text" size = "20" >
    State: < input class = "smallforms" id = "locationState" name = "locationState" type = "text" size = "2" >
    Postal code: < input class = "smallforms" id = "locationZip" name = "locationZip" type = "text" size = "8" > < br / >
    < br / >
    < table > < /tr >

    In your last code done selectAddress refers to "index" but I'm not declared or assigned. I think that you are missing 'var index = list.selectedIndex;' statement.

  • Hide the form field based on the name that contains some characters

    I think it's easy.

    We're looking for help with a script that allows you to hide all instances of text fields that contain a certain value. We have a running feature that applies to the same text fields, however, each text field should be labeled with a number at the end also running with this is a custom save button that flattens the page and hides some elements before the record on. The hide feature works pretty simple with "this.getField... = display.hidden; The problem is we do not want to repeat this step for each unique instance of fields that share the same name.

    We must look to each text box that has a similar title, so for example if we had several fields like that...  "my-text-field-01", "my-text-field-02" and "my-text-field-03" we want the script to find the "my-text field" name and hide all instances of that. ' "."

    Hope this makes sense, I'm sorry, our programming skills are still amateur. Thanks in advance for any help.

    You can do if you use a hierarchical naming convention. For example, instead of using something like: my-text - field.1, my-text - field.2, etc..

    You can then hide as well as:

    // Hide all of the "my-text-field" fields
    getField("my-text-field").display = display.hidden;
    
  • How can I show or hide a picture based on the size of the screen in CS6?

    I have a website created using Dreamweaver CS6. I used the checkerboard to fluid to hold different views for each of the 3 types - phone, Tablet, desktop computer. It works well, resizes properly. I would like to be able to show a picture in the desktop version but not the mobile version. How I do that? I can see in the .css file that the screens of different size can have their own different settings. Y at - it code I could add that could hide/show and image based on the users on the same page window? Let's say I have a div that is named photo. How could I add a parameter to the div photo in the stylesheet that would hide the image if it were mobile?

    Thank you

    Marilyn

    Thanks, I was able to change my code using your example and it works exactly as I wanted!

  • Auto-fill form fields based on the input from the end user?

    I am currently trying to create a new form that has a combo box 'Locations' with various options.  What I want to do, is to have another car to text field to fill out other fields associated with this location (for example, address, contact information) to save on time and reduce the possibility for the end user input errors.

    What are my options to accomplish such a task?  A form of bonding in the fields with a database of MS maybe?

    Thanks in advance for all advice and assistance on this subject!

    I created a sample for you... are a look and let me know if this is the case for you.

    Paul

  • Update form field based on the evolution of the Organization

    Hello Forum!

    This is my first post, as I'm new to IOM, I'll try to explain the problem as specific as possible.

    The situation:

    We have some sso devices, each of them associated with an organization with a search, so when you create a user, based on the name of the Organization, a predefined resource is associated with the identity. For this, we use an adapter pre-populate the form of resources.
    The problem arises when we move from a user to other agencies, I can't get this update automatically value.
    I capture the event of organizational change using the process task 'User to move' with a dummy adapter that returns true and calls the "Update SSOAPPLIANCE" task that downloads the device identification information.
    All tasks are running, but the form process remains the same.

    Is it what can I do to make this process of automatic update?

    Thanks in advance.

    Xisco Fernández.

    Hello

    I'm not sure, but if your type of variable is this resource, then you can set it as a String.OIM will convert him at length internally. If this isn't the case, then Yes you must get the key of the resource COMPUTER in the name of the resource and then update in the form of process.

    Let me know if you have any other questions.

    Concerning
    Nitesh

  • How to hide a field based on the value of a field of a different subform - controls null does not work!

    I use Javascript to define actions. I need to hide a text field, if the value of a field in another subsidiary form is zero.

    -J' tried to check the value in the other field NULL - does not work

    -J' tried affecting a variable str2 where I know that the value in the other field is available, then checking this variable when I initialize the text field - does not work

    What Miss me?

    Hello.

    Try this in the form of native void, referring to the text field (X).

    If (this.rawValue = 1)

    {

    X.Presence = "visible";

    }

    ElseIf (this.rawValue = null)

    {

    X.Presence = 'hidden ';

    }

  • show or hide text fields based on another text field value

    Hi, I have 3 text fields totals. by default, first text field is visible & other hidden two. what I want to do is if enter all the values in the first text box, other two text fields should automatically visible. Likewise, if I remove the value in the first text box, and then two other fields should automatically hide again. so thanks for giving me a java script for that. also I need javascript for hidden text fields. This script should check the values in the first field work and text (visible or hide). Thanks in advance...

    As the custom field the validation script enter this code (of course, set the names of the other fields as required):

    if (event.value=="") {
        this.getField("Field2").display = display.hidden;
        this.getField("Field3").display = display.hidden;
    } else {
        this.getField("Field2").display = display.visible;
        this.getField("Field3").display = display.visible;
    }
    
  • Primavera P6 R 7 - need help on hide a field based on the role

    I'm on P6R7 Primavera and to hide a gift of basic field rile to a level of activity.

    is this possible?

    You can not put the text. You can have a Code resource field and make them all Secure, but you need to come up with answers possible HR you want to join.

  • Autopopulate need a field based on the selection of a field of LOV

    Hi all

    I have a requirement as below.

    I have a LOV field in my custom the OPS page by selecting a value from the lov, I need autopopulate another field of text in my custom page of OFA, please help me on how to do this.

    Thank you

    Hello

    If you get this value in processRequest means, you can use the following code.

    {

    Integer a;

    a = ResultSet.GetInt ("CCU_ID");

    System.out.println ("partid is:" + a);

    OAMessageTextInputBean oaApp = (OAMessageTextInputBean) webBean.findIndexedChildRecursive ("text");

    oaApp.setValue (pageContext,a);

    }

    Assume that if you get this value firePartialAction or processFormRequest means this field of messageTextInput must be associated with some VO, so that you can view the value of vo when running.

    Thank you and best regards,

    Myvizhi

  • show/hide fields based on the drop-down list of choices

    I have a field from the drop-down list with three choices. Based on the selection, I need a specific text form field to appear and the others to stay hidden. (Or if it makes the code cleaner, the resulting field could be a drop-down list, too, with the selected choice.) I don't know Java well enough to extrapolate the code from the examples online and it fit my forms. I can provide an example of form. Thanks in advance for your help.

    There are ways to run this.  the easiest for you would be to add this script to the event (calculation of the Properties tab) to calculate the field that must be hidden.  Take notes, all "/ /" is some tips for you to understand the code.  You will need to put this script in all the areas you want to replicate the behavior, change the value depending on what you want to accomplish.  the word 'event' means myself to make you understand.

    If (this.getField("dropdown").value == 'put value here') {//replace "drop down" with the name of the drops}

    Event.Target.Display = display.visible;

    }

    else {}

    Event.Target.Display = display.hidden;

    }

    This works if you have a small amount of fields.  If you manage to have a large number of similar fields, let me know because there are other, faster ways.

  • In: toggle a field based on the State of a checkbox

    Hi all
    I have a tabular form on a single table. The table has a Y/N column type. So to see this checkbox column I followed excellent tutorial http://www.inside-oracle-apex.com/checkboxes-in-tabular-forms-the-easy-way/ Patrick

    It works very well. But now I also want to turn another field based on the question of whether this check box is checked or not. To do this, I followed another post on how to do it and it also works. But the problem is when I try to save the form, I get the dreaded MRU error.

    Tabular form fields
    NAME, SALARY, ACTIVE

    NAME-> Normal text box
    SALARY-> I want this field to be enabled/disabled based on the value of the last column ENABLED_CHECKBOX
    ENABLED_CHECKBOX-> it's a checkbox (created by following the tutorial of Patrick)

    What I did to make SALARY toggle dynamically (it works, but I get error MRU registration)
    Change ENABLED CHECKBOX_
    ENABLED_CHECKBOX-> This is a standard report with the following HTML Expression field:
    "< pre > < input type ="checkbox"#ENABLED_CHECKBOX # value =" "#ROWNUM #" name = "f40" id = "f40_ #ROWNUM # ' class = 'MyClass' / > < / pre >


    Additional dynamic action
    WHEN = change event
    Selection type = jQuery Selector
    JQuery Selector = .myClass
    Condition = no requirement

    Real Action = run Javascript

    Code =
    < pre >
    column_2_id = "f02_000" + $(this.triggeringElement).attr('id').substr (4);

    If (.attr ('checked')) $(this.triggeringElement)
    {
    $("#"_+_column_2_id).attr ("disabled", "disabled");
    }
    on the other
    {
    $("#"_+_column_2_id).attr ("disabled", false);
    }
    < / pre >

    Sylvie,

    You must reactivate the fields before being submitted, because the disabled fields are not subject at all - and that throws what APEX collections uses tabular forms. See my post here.

    Short version: use something like this as an action dynamic javascript before submitting the form:

    $('input:disabled').attr('disabled',false);
    

    -David

  • Vary the accounts based on the selection of feature in data form

    Hi all

    I use Hyperion Planning 11.1.1.0.

    I have a problem by varying the members accounts on the dataform based on the selection of members of the entity of the dimension of the page.

    Currently, we use the Begbalance as a member (column) in the dataform and kept hidden. And we set the value of Begbalance-> actual values to zero for accounts that correspond to a specific entity...

    Then, on the form, I put 'delete missing data... That way I can show the accounts that should appear for an entity.

    But the list of members of the entity has more than 200, and thus also the accounts.

    Therefore, it is very tedious to do this adjustment for them...

    Someone please you suggest a better way to achieve the same * (i.e. different accounts on the dataform based on a selection of entity?) *.

    Kind regards.

    Alicia

    Hello

    You use the technique that a lot of consultants allows you to control what is displayed on a form.
    How do you set the values, if you have an excel template that you just update and then send the data to essbase it can facilitate the management of it a little.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

Maybe you are looking for