Select Option Custom Tag JQUERY

I have multiple select options on many of my pages, I just just added a jquery filter plugin to one of the select options i.e As User types on an input box the values in the select options gets filtered. This works very well now. How can I make it this into a custom Tag where it can be resused by all the select options on the site. That is the id of the select option and the input box has to be passed to the jquery to automtically filter the content of the Select Option. below is my jquery script.
<div>Filter<br>
    <input id="txtcomm" type="text" name="">       
</div>
<div>
    <select id="slctcomm" multiple style="width:220px">
        <cfloop query="qryobjComm">
            <option value="#Comm#">#Comm#</option>
        </cfloop>
    </select>   
</div> 
<script>
    jQuery.fn.filterByText = function(txtcomm, selectSingleMatch) {
      return this.each(function() {
        var slctcomm = this;
        var options = [];
        $(slctcomm).find('option').each(function() {
          options.push({value: $(this).val(), text: $(this).text()});
        $(slctcomm).data('options', options);
        $(txtcomm).bind('change keyup', function() {
          var options = $(slctcomm).empty().data('options');
          var search = $.trim($(this).val());
          var regex = new RegExp(search,'gi');
          $.each(options, function(i) {
            var option = options[i];
            if(option.text.match(regex) !== null) {
              $(slctcomm).append(
                 $('<option>').text(option.text).val(option.value)
          if (selectSingleMatch === true &&
              $(slctcomm).children().length === 1) {
            $(slctcomm).children().get(0).selected = true;
    $(function() {
      $('#slctcomm').filterByText($('#txtcomm'), true);
</script>

Hi umuayo,
I guess you want pass the jquery selector for textbox and selectbox. I have created a file named filterByText.cfm which will act as customtag for me.
for more information regarding custom tag follow this link http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b2e1 -7fff.html
In this example i have created custom tag in the same directory where I will use it. You can create it in different place also. Let us get into the main topic. I will pass the jquery selector for textbox and selectbox to the custom tag by "FilterId" and "slctcomm" attribute and inside customtag I will convert coldfusion valiable to javascript variable and use them to call your function.
dynamicselectbox.cfm
CODE:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<cfquery name="getEmps" datasource="cfdocexamples">
    SELECT * FROM EMPLOYEE
</cfquery>
<div>Filter<br>
    <input id="txtcomm" type="text" name="">      
</div>
<div>
    <select id="slctcomm" multiple style="width:220px" class="selclass">
        <cfoutput query="getEmps">
            <option value="#Emp_ID#">#FirstName#</option>
        </cfoutput>
    </select>
          <select id="slctcomm2" multiple style="width:220px" class="selclass">
        <cfoutput query="getEmps">
            <option value="#Emp_ID#">#FirstName#</option>
        </cfoutput>
    </select>  
</div>
<cf_filterByText FilterId="##txtcomm" slctcomm=".selclass">
filterByText.cfm
Code:
<script type="text/javascript">
//get the jquery selector from attribute scope
          var filterId="<cfoutput>#Attributes.FilterId#</cfoutput>";
          var selectBoxId="<cfoutput>#Attributes.slctcomm#</cfoutput>";
    jQuery.fn.filterByText = function(txtcomm, selectSingleMatch) {
                    console.log(this);
                    var retvar;
        retvar = this.each(function() {
        var slctcomm = this;
        var options = [];
        $(slctcomm).find('option').each(function() {
          options.push({value: $(this).val(), text: $(this).text()});
        $(slctcomm).data('options', options);
        $(txtcomm).bind('change keyup', function() {
          var options = $(slctcomm).empty().data('options');
          var search = $.trim($(this).val());
          var regex = new RegExp(search,'gi');
          $.each(options, function(i) {
            var option = options[i];
            if(option.text.match(regex) !== null) {
              $(slctcomm).append(
                 $('<option>').text(option.text).val(option.value)
          if (selectSingleMatch === true &&
              $(slctcomm).children().length === 1) {
            $(slctcomm).children().get(0).selected = true;
            return retvar;
//call the function with the selector passed by user.
    $(function() {
      $(selectBoxId).filterByText($(filterId), true);
</script>
Thanks
Saurav

Similar Messages

  • Set Parameter for Select Option & Customized field

    Hi All,
    I had 2 questions here:
    1. This field in the report is a customized field and did not have any parameter.
        Is there any way to set the parameter for such fields?
    2. This field is a select option in the report.
        How can i set the parameter for the select option with lower and higher range?

    >
    Sally Teo wrote:
    > Hi All,
    >
    > I had 2 questions here:
    >
    > 1. This field in the report is a customized field and did not have any parameter.
    >     Is there any way to set the parameter for such fields?
    ----> plz ref ur prev.Post.
    >
    > 2. This field is a select option in the report.
    >     How can i set the parameter for the select option with lower and higher range?--->
    i dont think its possible to give High/low values to them, better to write small BDC to pass the data.
    regards
    Prabhu

  • RowKey dataitem and select-option HTML tags

    Hi,
    I would like to select a dataitem of a datasource in a single selection combobox like EmployeeName and when I submit the form I would like to get the RowKey directly !
    HOW TO YOU DO THAT ??
    I tried the code below but I had this JBO exception :
    javax.servlet.jsp.JspException: JBO-25002: Definition RowKey of type Attribute not found
    Here the code :
    <form name="formRech" method="get" action="Frameset.jsp">
    <select name="select" size="4" class="CHAMP">
    <jbo:RowsetIterate datasource="ds">
    <option>
    <jbo:ShowValue datasource="ds" dataitem="EmployeeName"/>
    <jbo:InputHidden datasource="ds" dataitem="RowKey"/>
    </option>
    </jbo:RowsetIterate>
    </select>
    </form>
    Thank's

    I found the response.
    For someone interested :
    <option value="<jbo:ShowValue datasource="ds" dataitem="RowKey"/>">
    <jbo:ShowValue datasource="ds" dataitem="EmployeeName"/>
    </option>
    null

  • Select option greyed out for fields of custom DataSource (rso2, rsa6)

    Hi
    Why are several fields, in my custom DataSource (created in rso2) not available for select?
    I do not think this is a permission issue, since several fields are selectable, but not all fields.
    It is not the data type, since I see other custom DataSources that have the same data type, and it is selectable as a select option.
    This is not a DataSource that was provided by SAP, it is completely custom, and uses a custom data definition (defined as a structure via se11), and a custom function.
    I have read the responses to similar questions, but have not found an answer that explains how to make the field selectable for select.
    What determines which fields can be selected for selection, and which fields have this option greyed out (not selectable)?
    I have come across multiple answers, for similar questions, that suggest an abap program to directly update table roosfield.
    Is this safe?
    IF I choose this route will I need to run the update program on production, or will the change it makes to my dataSource transport with my transport?
    (I can test this).
    What I most need to know is If this suggestion is safe, or if it has side effects?
    Thank you

    Hi Eileen,
    In Least case to enable the selection for the fields with the below program:
    Below code is for your reference which will use to unhide objects in RSO2 or RSA6 for Data source( in code for BELNR, KUNNR, VBELN, BUDAT fields are unhiding for 0fi_ar_4 data source selection option) . Still need any clarifications let me know.
    SE38: Create a program for ref below code.
    REPORT ZNP_SELE_DS.
    tables: ROOSFIELD.
    UPDATE ROOSFIELD SET SELECTION = 'P'
    WHERE OLTPSOURCE = '0FI_AR_4' AND   OBJVERS = 'A' AND FIELD = 'BELNR'.
    UPDATE ROOSFIELD SET SELECTION = 'P'
    WHERE OLTPSOURCE = '0FI_AR_4' AND OBJVERS = 'A' AND FIELD = 'KUNNR'.
    UPDATE ROOSFIELD SET SELECTION = 'P'
    WHERE OLTPSOURCE = '0FI_AR_4' AND OBJVERS = 'A' AND FIELD = 'VBELN'.
    UPDATE ROOSFIELD SET SELECTION = 'P'
    WHERE OLTPSOURCE = '0FI_AR_4' AND OBJVERS = 'A' AND FIELD = 'BUDAT'.
    Thanks & Regards,
    Srinu.Rapolu

  • Printing web page with select tags in IE9 and a .cfm file-only the original selected option prints

    My web page has a select tag and cfselect tags and when I print the page with a different option other than the originally selected option the print for both types of select tags reverts back to the original selection and ignores the new selection.  This happens in IE9 and .cfm files but not when the page is printed in IE8 or IE7 modes (tried in the F12 Developer Tools.)  It also needs to be a .cfm file.  FireFox printed the pages correctly for any combination.
    This was done on a Dell and ThinkCentre computers under Windows 7.  Also, I was able to reproduce the same problem on an different university web site where a selection box would revert back to the original selection for printing on a .cfm page and would print properly on a .PHP page at the same site.
    For my site, I used a print button which calls print() and right clicked and chose print and got the same results no matter which method was used.  I only had the right click method on the third party web site.
    I know this is probably a bit narrow an issue but, any help would be appreciated.

    It appears that it is probably an IE9 bug.
    I simplified the problem by turning the page source taken from the brouser of the original .cfm into an html file and found that it would still print improperly.
    When I eliminated the various parts of the file I found that it would print correctly only when I removed the first line, the "DOC type" line.
    The page will print the newly selected option but then I lose the style sheet.
    If it does not work in an HTML file it must be IE.  It is not the .cfm.  The reason that it did not work for .cfm files, is that they always have a "DOC type" statement.
    I have put the issue into an MSDN forum in addition to the one mentioned previously.

  • Select Options in custom controller

    Hi,
    Any one please let me know how to put select options on custom container. I need to display select options based on the input a tree and a report should be displayed in the same screen along with input screen.
    So I planned object oriented program to split screen to display tree and report. and again I split left side container to 2 containers. Now I want put the selection screen on left top container.
    Please help.
    Chandra

    What you can do is the following:
    Define a Container Object on one side of the screen to place the ALV Tree, and a Subscreen area on the other side, so you can place your select-options right there:
    You can define the select-options this way:
    SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
    SELECT-OPTIONS : s_ebeln FOR ekko-ebeln ,
    s_ebelp FOR ekpo-ebelp .
    SELECTION-SCREEN END OF SCREEN 100 .
    And then in the flow logic of your dynpro, assign this selection screen to your subscreen area. (Called SUB1 in this case)
      call subscreen sub1 including sy-repid '0100'.
    Regards

  • How to pass standard program selection  options to custom program?

    Hi... i want to use standard program select-options in a custom program.. actually in a custom program i'm using one standard program  and one custom program. standard program contains selection scren. i want to use that selection screen in custum program.
    can anybody please provide solution for this.
    looking forward for ur updates

    first you must find where the selection screen logic is written in standard one.once you get this details than you may Include the same screen and include program in your zprogram.and here your work is not finished you may need to do some change apart from copy all this details.
    Amit.

  • Select-Option tags in HTML

    I used Select-option tag in HTML. Suppose name of the Select tag is 'abc'. what is the property of 'abc' object to get it's value in JavaScript.

    // This will return the value for the Selected item
    if(document.forms[0].abc.selectedIndex!=-1){
      alert(document.forms[0].abc[document.forms[0].abc.selectedIndex].value);
    }I think this should help

  • Multiple selection tab on Custom F4 of select option in report

    Hi folks ,
      how to get MULTIPLE SELECTION tab on extension of my selec option of report screen.
    If i pass Multiple_choice = 'X' in fm 'F4IF_INT_TABLE_VALUE_REQUEST' check boxes are appearing of each my f4 values when i press f4, i dnt want like this i want it my extension as Multiple selection as how it appears for standard 4 helps.
    <removed by moderator>
    Thanks,
    Shwetha
    Edited by: Thomas Zloch on Jan 7, 2012 10:32 PM

    Hi Clemen,
    Any selectin screens element(select-option) if we click on extension we will get a pop up window with  SINGLE VALUES,SELECT RANGES,EXCLUDE SINGLE VALUES, EXCLUDE RANGES bottome of this window we are having some icons along with it we have MULTIPLE SELECTION Tab.if we click on multiple selection tab we will be getting our all values with checkboxes each front of it so that we can select multiple vlaues at a time for the particular f4 .
    i want this multiple selection tab for my custome F4, iam not getting this MULTIPLE SELECTION tab.
    for example you can check for select-option of account group(T077D-KTOKD).
    in F4 function module if iam using paramter MULTIPLE_CHOICE = 'X', iam not getting the extension pop window with singlevalues, select ranges etc ., instead of it iam getting all my f4 fields with the checkboxes infront of each of it.
    please throw some light it is very urgent.
    please tell me iam using following parameters in function module please let me know if i need to use any other to get it..
    with the following if iam selecting multiple also i am able to see only last value in selection(inpopup window)
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'ATWRT'
          dynpprog        = sy-cprog
          dynpnr          = sy-dynnr
          dynprofield     = 'S_CHVAL1-HIGH'
          display         = c_sp
          value_org       = c_s
          multiple_choice = 'X'
          callback_program = sy-repid
        TABLES
          value_tab       = t_finals
          return_tab      = t_return4
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc = 0.
        READ TABLE t_return4." WITH KEY retfield = 'S_CHVAL1'.
        IF sy-subrc EQ 0.
          s_chval1-high = t_return4-fieldval.
        ENDIF.
      ENDIF.
    Thanks,
    Shwetha
    Edited by: swetha rishi on Jan 8, 2012 11:15 AM

  • Innput field with Select option on custom screen

    Hi,
    I need to create an Input field with Select Option(No interval) button on Custom dialog screen .
    Is there any idea how can I create it on screen ?
    Thanks
    Sachin

    create a normal inputfield and place an icon next to it. then in the pai on click of that button use the following code.
    data: wf_tab_field like rstabfield occurs 0 with header line ,
          wf_exl_opt like rsoptions .
    refresh: wf_tab_field  .
        move: 'KOSTL' to wf_tab_field-fieldname ,
              'CSKS' to wf_tab_field-tablename .
        append wf_tab_field .
        clear wf_tab_field .
        move: 'X' to wf_exl_opt-bt ,
              'X' to wf_exl_opt-cp ,
              'X' to wf_exl_opt-ge ,
              'X' to wf_exl_opt-gt ,
              'X' to wf_exl_opt-le ,
              'X' to wf_exl_opt-lt ,
              'X' to wf_exl_opt-nb ,
              'X' to wf_exl_opt-np .
    call function 'COMPLEX_SELECTIONS_DIALOG'
         exporting
           title                   = 'Select Cost Centers'
           text                    = 'Cost Center'
    *         SIGNED                  = 'X'
    *         LOWER_CASE              = ' '
    *         NO_INTERVAL_CHECK       = ' '
    *         JUST_DISPLAY            = ' '
    *         JUST_INCL               = ' '
            excluded_options        = wf_exl_opt
    *         DESCRIPTION             =
            help_field              = 'CSKS-KOSTL'
    *          SEARCH_HELP             = 'KOST'
            tab_and_field           = wf_tab_field
          tables
            range                   = r_kostl
         exceptions
           no_range_tab            = 1
           cancelled               = 2
           internal_error          = 3
           invalid_fieldname       = 4
           others                  = 5
        if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
        if not r_kostl[] is initial .
          read table r_kostl index 1 .
          if sy-subrc eq 0 .
            move: r_kostl-low to wf_t_kostl .
          endif .
        endif .
    wf_t_kostl  is the screen field name.
    Raja

  • How to pass values to select options of custom transactions?

    I have to call custom transaction-ZMM_POST  from my custom report.
    I have to pass values to select options(Not to parameters) of ZMM_POST  from my report only.
    Please tell me how to pass values to select options of custom transactions?

    Have you tried this?
    DATA: T_RSPARAMS TYPE STANDARD TABLE OF RSPARAMS WITH HEADER LINE.
    T_RSPARAMS-SELNAME = "S_BUKRS".
    T_RSPARAMS-KIND = "S".
    T_RSPARAMS-SIGN = "I".
    T_RSPARAMS-OPTION = "BT".
    T_RSPARAMS-LOW = "100".
    T_RSPARAMS-HIGH = "300"
    APPEND T_RSPARAMS.
    SUBMIT Z_DUMMY WITH SELECTION-TABLE  T_RSPARAMS.
    Greetings,
    Blag.

  • Error V0 104 while adding select option on customized screen

    Hi all,
    I have a screen added on the standard transaction IW21 (with selection screen definition and called like subscreen). On this screen I have some SELECT-OPTIONS and when I press the button of selecting multiple values, I get the following message: "Requested function & is not available here" (V0 104), where & is long number starting with %..I have added entries to the tables T185F and T185 with the transaction VFBS, but I dont know how to assign the Function codes to SELECT-OPTIONS..
    Thanks in advance for feedback!
    Anna
    Edited by: Anna L on Jul 16, 2008 11:03 AM

    Just an explanation: no matter the error message I get, the values are transferred correctly from the multiple selection screen to my screen.
    I hope somebody got similar case and can give me some hint...
    Thank you,
    Anna

  • How to retrieve data using logical database and custom select options

    Hi all,
    I have a selection screen which is displayed by logical database PSJ and I have two select options of my own. I need to retrieve data based on both selection screen of logical database and my own select options. How can I do it?
    Thanks in advance.

    Hai Gupta
    Check the following Document & Links
    1. A logical database is in fact
    a program only.
    2. This LDB provides two main things :
    a) a pre-defined selection screen
    which handles all user inputs and validations
    b) pre defined set of data
    based upon the user selection.
    3. So we dont have to worry about from
    which tables to fetch data.
    4. Moreover, this LDB Program,
    handles all user-authorisations
    and is efficient in all respects.
    5. tcode is SLDB
    good info about Logical Database. you can check the link.
    http://www.geekinterview.com/question_details/1506
    http://help.sap.com/saphelp_46c/helpdata/EN/35/2cd77bd7705394e10000009b387c12/frameset.htm
    Re: How to Create and Use ldb in reports?
    Re: Logical databases
    http://help.sap.com/saphelp_46c/helpdata/en/9f/db9bed35c111d1829f0000e829fbfe/frameset.htm
    Functions for displaying and changing logical databases:
    Call Transaction SE36 or
    Choose ABAP Workbench -> Development -> Programming environ. -> Logical databases
    Interaction between database program and report:
    During program processing, subroutines are performed in the database program and events are executed in the report.
    To read data from a database tables we use logical database.
    A logical database provides read-only access to a group of related tables to an ABAP/4 program.
    advantages:-
    The programmer need not worry about the primary key for each table.Because Logical database knows how the different tables relate to each other,and can issue the SELECT command with proper where clause to retrieve the data.
    i)An easy-to-use standard user interface.
    ii)check functions which check that user input is complete,correct,and plausible.
    iii)meaningful data selection.
    iv)central authorization checks for database accesses.
    v)good read access performance while retaining the hierarchical data view determined by the application logic.
    disadvantages:-
    i)If you donot specify a logical database in the program attributes,the GET events never occur.
    ii)There is no ENDGET command,so the code block associated with an event ends with the next event
    statement (such as another GET or an END-OF-SELECTION).
    1. transaction code SLDB.
    2.enter name z<ldb-name>
    3.create
    4.short text
    5.create
    6. name of root node (here Ekko)
    7. enter short text (f6)
    8.node type -> data base table.
    9.create
    10 change logical DB
    riht click on ekko and insert node
    here node name ekpo
    11.create
    12. click on selections
    13. press no Should the changed structure of Z<ldb name> be saved first.
    14.select tables which you want to join.
    15.transfer
    16 now you have to o to coding part.
    17. save
    activate.
    19.click to src code
    double click on first include and activate
    Regards
    Sreeni

  • SELECT-OPTIONS on custom screen problem

    Hi all,
    I have a screen added on the standard transaction IW21 (with selection screen definition and called like subscreen). On this screen I have some SELECT-OPTIONS and when I press the button of selecting multiple values, I get the following message: "Requested function & is not available here" (V0 104), where & is long number starting with %..No matter the error message, the values are transferred correctly from the multiple selection screen to my screen. I have added entries to the tables T185F and T185 with the transaction VFBS, but I dont know how to assign the Function codes to SELECT-OPTIONS..
    Thanks in advance for feedback!
    Anna

    Hi, this is copied from SELECT-OPTION documentation:
    The LOW and HIGH fields of a selection option are displayed in a length up to 18 bytes long (scrollable up to 45 bytes). If you define a length longer than 45, fields are truncated on the selection screen after the 45th character. This affects the first line of the SELECT-OPTIONS table. You can, however, use SUBMIT to pass longer selection options to a report if they are specified with the addition NO-DISPLAY and thus do not appear on the selection screen. Without NO-DISPLAY, the fields are then truncated whenever the selection screen is processed in the background ( SUBMIT without VIA SELECTION-SCREEN).
    regards,

  • Select Option on Selection Screen with custom description

    Hi experts,
    I have used select options and some parameters on selection screen. But is displaying the only the field names i want to display the description instead of field name. Here is the screen
    Like instead S_ANSDT is Acquisition Value and instead of P_CPI is should be CPI and instead of P_TEST it will be like PROCESS.
    The code is like
    SELECT-OPTIONS:
       s_ansdt  FOR equi-ansdt.                                                     
    PARAMETERS: p_cpi(3) TYPE p DECIMALS 2,
                 p_test AS CHECKBOX DEFAULT 'X'.
    If any body have any idea please share it with me.
    Thanks,
    Avadhut

    Hello,
    You can give a description to your parameters and select options from menu Goto / Text elements / Selection texts.
    Óscar

Maybe you are looking for

  • How do I fix my unbalanced body error?

    Hi, I am new to dreamweaver cs6 and I DESPERATELY need help! Every I go to save a template or create a new page from the template, I get an error message saying.... There is an error at line 149 "***": unbalanced body tag. I've been through several f

  • Events on External Drive not showing up in Event Library

    Hi, I spent several hours last night importing nearly a Terabyte of iMovie events into FCP X.  It took forever, but seemed to work - all my iMovie events appeared in the FCP Event library. Today, when I started up FCP X, my external drive appears in

  • Graphic Driver upgrade

    I need to upgrade my graphic driver (current version is 295.62) is this a software or hardware issue? And how can I tackle the issue? This question was solved. View Solution.

  • How to find out first words in a sting

    Hi All, I have a requirement to find out first two words in a string by using SQL. Your help will be more appreciated. Thank you,

  • Setting in compressor to DVD Studio pro

    Hello Need some help with compressor. The matter is that I have a QT video ( Video Format: RLE. Codec ID: rle. 35min. Bit rate 226Mbps 720 x 576 PAL. Display ratio 5:4. Frame rate mode: variable. Frame rate: 25. 55GB. Bits( Pixelframe): 22,217. Audio