Changing a select list using javascript

Hi all,
yesterday I had a doubt using apex_item.checkbox and how to change them using javascript:
Re: Passing a checkbox as a parameter to a javascript function
Today, I'm facing a similar problem, but with select lists. Here it goes. I have a report with apex_items, like this:
select
apex_item.checkbox(1,"ID",NULL,NULL,NULL,'f01_#ROWNUM#') " ",
apex_item.select_list_from_lov(2,"SW_STATUS",'F2010051_SET_STATUS','onChange="setItems(''f01_#ROWNUM#'',''f03_#ROWNUM@'')"','NO') sTATUS,
apex_item.select_list_from_lov(3,"REVISIO",'F2010051_SET_REVISIO',NULL,'NO','f04_#ROWNUM#') "REVISIO"
from Fx1_vThe javascript code is as follows:
<script type="text/javascript">
function setItems(cb,estat){
  elem = $x(cb);
  alert(elem.value);
  $x(cb).checked = true;
  elem2 = $x(estat);
  alert(elem2.value); 
</script>The idea is that everytime the item g_f02 (a select list) changes, calls the JS function with two parameters: a checkbox (g_f01) and another select list (g_f03). The function should change the items to a defined values. The checkbox changes ok thanks to the help I got yesterday, but I can't work with the third item (select list g_f03). When I try to show the value, it says "undefined".
how could I see the actual value of the select list LOV and change it to 1, for example?
Thank you very much, any help will be appreciated!!!
Edited by: Elena.mtc on 19-may-2011 8:11

Hi,
Do you have typo in query?
Should it be
select
apex_item.checkbox(1,"ID",NULL,NULL,NULL,'f01_#ROWNUM#') " ",
apex_item.select_list_from_lov(2,"SW_STATUS",'F2010051_SET_STATUS','onChange="setItems(''f01_#ROWNUM#'',''f03_#ROWNUM#'')"','NO') sTATUS,
apex_item.select_list_from_lov(3,"REVISIO",'F2010051_SET_REVISIO',NULL,'NO','f04_#ROWNUM#') "REVISIO"
from Fx1_vAnd JavaScript
<script type="text/javascript">
function setItems(cb,estat){
  elem = $x(cb);
  alert(elem.value);
  $x(cb).checked = true;
  elem2 = $x(estat);
  alert(elem2.value); 
  $s(elem2,1); // $s function is for changing item value
</script>Regards,
Jari

Similar Messages

  • How to get Saved Selection list in javascript?

    Hello!
    Recently I met a little problem about save selection. I want to get saved selection list so that I can used in javascript. Now I have no ideals. Hope you tell me some useful information about how to get Saved Selection list in javascript!

    Mark is right, it's not possible.
    But do you know you can assign selection to a variable, and get back to it simply like this?
    var sel = app.selection;
    app.selection = null;
    /* your codes here
    app.selection = sel;

  • Create a select list using AJAX

    Hello,
    I saw Carl Backstrom and Scott Spendolini examples on how to use AJAX to populate a related item, based on a select list. What I'm looking for is the reversed angle.
    I have a TextItem, and I want to generate a select list based on that TextItem, something like this:
    select code, desc
    from Table
    where code like TextItem
    Is it possible with AJAX? (in the current examples I gat lost in the on demand application process – How, if possible, to render the select list using the HTP package.)
    Greatly appreciate the help
    Arie.

    Carl,
    I hope you can help with this, from reading the forum, you seem to have a lot of experience with AJAX and Application Express. I have found your examples within the forums and can not get them to work on my servers. I am on version 2, and a 10g database. I am attempting to place 4 select lists on a page. Each one (with exception from the first) will be dependent on the previous. To make is simple I have started with only 2 select lists. The first select list (p1_select1) is a list of departments. The second list (p1_select2) should populate with the users who belong to the department selected from p1_select1. I can not seem to get the second select list to load. I have attempted to follow your code as best I could, I can see on the page that it has created the xml data, however it just does not populate the second select list. Here is a summary of what I have.
    Thanks for lookin.
    Mike
    Page Regions:
    HTML: main (10)
    Region Header:
    <script language="JavaScript1.1" type="text/javascript">
    function f_Get_Data(pThis,pSelect_Source,pSelect_Target){
    var l_Return = null;
    var l_Select = html_GetElement(pSelect_Target);
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=Get_Data',0);
    get.add(pSelect_Source,pThis.value);
    gReturn = get.get('XML');
    if(gReturn && l_Select){
    var l_Count = gReturn.getElementsByTagName("option").length;
    l_Select.length = 0;
    for(var i=0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("option");
    appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
    get = null;
    function appendToSelect(pSelect, pValue, pContent) {
    var l_Opt = document.createElement("option");
    l_Opt.value = pValue;
    if(document.all){/* why is ie different ask bill */
    pSelect.options.add(l_Opt);
    l_Opt.innerText = pContent;
    }else{
    l_Opt.appendChild(document.createTextNode(pContent));
    pSelect.appendChild(l_Opt);
    </script>
    Items
    Region: main
    10: P1_TEXT1 Select List
    20: P1_TEXT2 Select List
    P1_TEXT1 Form Element:
    onChange="javascript:f_Get_Data(this,'P1_TEXT1','P2_TEXT2')";
    APPLICATION PROCESS "On Demand" Get_Data:
    declare
    begin
    owa_util.mime_header('text/xml', FALSE );
    htp.p('Cache-Control: no-cache');
    htp.p('Pragma: no-cache');
    owa_util.http_header_close;
    htp.prn('<select>');
    for rec in (select ENAME , EMPNO
    from EMP where DEPTNO = :P1_text1) loop
    htp.prn('<option value="' || rec.EMPNO || '">' || rec.ENAME || '</option>');
    end loop;
    htp.prn('</select>');
    exception
    when no_data_Found then
    null;
    end;

  • Set select list using description

    Hi,
    I have been able to provide a value for a select list from another page when providing a code in the P6_NAME field e.g. P5_NAME_ID = &P6_NAME.
    I now need to choose an option from a select list using it's description rather than the underlying code the field is based on.
    Is this possible?
    Toby

    So if no other value has been specified already you just want the select list to have a default item already selected, right? OK, how about setting the Default Value Type for the Select List to "PL/SQL Function Body" and setting its Default to:
    DECLARE
       l_return_id number;
    BEGIN
       SELECT id
       INTO l_return_id
       FROM my_lookup_table
       WHERE description = 'Description of your default lookup value';
       return l_return_id;
    END IF;Andy

  • Dynamic changes of option tags in a Select tag using JavaScript

    I got this problem during my project.
    I used Select tag in HTML code.
    I have to change options related to Select tag, based on events.
    How can we change options dynamically using JavaScript?
    Please post solution to this problem..

    You know Sun Java Studio Enterprise forum isn�t a right place for JavaScript & HTML questions.
    BTW here is you can find a lot of js stuff: docs, samples, tutorials, etc:
    http://www.w3schools.com/js/default.asp

  • Unable to add items to dropdown list using javascript

    Hi,
    I'm trying to add additional items to a dropdown list at runtime using javascript.
    I'm doing this by invoking the addItem method on the dropdown list field during its initialize event.
    However when I run the generated pdf in Acrobat Pro, I get the following error in the console -
    GeneralError: Operation failed.
    XFAObject.addItem:3:XFA:form1[0]:#subform[0]:field0[0]:initialize
    Method: 'addItem' cannot be called because doing so would violate this document's permissions settings.
    The pdf form has no signatures or any other stuff in it.
    What additional permissions do I need to add and how ?
    You can view the pdf here -
    https://dl.dropboxusercontent.com/u/8022836/xfa3_test.pdf
    Thanks,
    Joel

    Is there a reason to use the code you did? It looks like the problem is with the variable's permissions when going through the template.
    This code works just fine in that same event:
    this.addItem("new item");
    As does:
    var f = xfa.resolveNode("form1.#subform1[0].field0");
    f.additem("new item");

  • Dynamically changing the select list in an LOV based on the login user

    We have a field in a form which is a combobox.The form is to be linked to different profiles of users.Based on the logged in user we would like to restrict the select list in the LOV.ie user1 should see a LOV which is different from that seen by user2.Is this possible.If so how can this be done?Kindly reply.
    Thanks & Regds,
    Jayanthi

    Thanks for ur reply.But my problem is that i have a table having details of some products which includes spareparts also(Name,id,price etc).In my form i have the combobox field which should have a list of these products which the user can select.Now depending on the user's profile he should see only his related products(One profile of users should view only the products but not the spares while the other should view only spares.)The details of both the products and spares are in the same table.we have a criteria to differentiate between the products and the spares.The LOV should display at run time, either products or spares depending on his profile as he logs in. Hope u understood my problem.
    Regds,
    Jayanthi
    Hello Jayanthi,
    I had a similar situation in my last project.
    While you can solve this by modifying your query, this will always come around as may be later some other criteria to restrict based on User/His Role/Something else. Hence I fixed it at design level itself. Though I can't give my situation I can tell you the solution applying my logic.
    Altering your Product Table and adding one more database Column say Product_Category and updating the table with Product Category =1 for Products and 2 for Spares. You can extend this further for other types.
    Create a new Table say User_Groups that will have
    Group_id
    Group_Name
    User_Id columns and will contain all the User ids inserted groupwise.
    Create one last Table Group_Product_Map
    That will have
    Group_id
    Category_id
    This will store each Group_Id followed by Category_id of Products to which these group members will have access to.
    Now write a database function getCategory( p_User) which will query User_Groups table to get Group_Id
    and further query Group_Product_Map Table based on group_id to get Category_Id.
    This function will return category_id.
    Huh!
    So your LOV will have a query as select *(or whatever) from Product where category_id = getCategory(portal30.wwctx_api.get_user)
    Hope this helps
    Madhav

  • Need Help on Select list using AJAX

    Hi ,
    I have a 3 select list in the application,
    2nd select list depends on 1st, 3rd depends on 1st and 2nd.
    I have created application items and process and java script, but for some reason i can not pass 2 application items values to the process.
    Please any idea or example. I have followed dennis site for creating cascade select demo application.
    Thanks
    KP

    Did you have a look at this thread:
    Problem with Dynamic Select Lists
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How do you clear a select list in javascript?

    Hi,
    I've tried clearing a select list (after it has been populated) by
    html_GetElement('P_CAMPUS').value='';
    html_GetElement('P_CAMPUS').value=null;
    these clear the visible field but if you click it all the options are still there.
    I tried:
    html_GetElement('P_CAMPUS')=null'';
    It is probably a real easy thing... but I don't see it...\
    Thanks, BillC

    To delete all the options in the select/dropdown list, you go
    html_GetElement('P91_SELECT').options.length=0;

  • Can I create  a multi-selection list using a dynamic list of values?

    I'm reading section 19.7.3 from the dev guide - it explains how to create a selectOneListbox using a dynamic list of values. Is it possible to create a multi-select listbox from a dynamic list of values?
    What I would like to do - I have a read-only view object with a hard-coded query - I would like to display the results of the query in a dropdown list box, or dropdown list box with boolean checkboxes, to allow the user to select multiple items from the list. How can I accomplish this?
    thanks

    Hi JavaX,
    I don't know of any JSF components (at least not any ADF Faces components) that lets you do multiple selection in a drop-down. There is an af:selectManyListbox, but it does not render as a drop-down.
    John

  • Tracking the Date time changes in DatePicker control using Javascript/JQuery

    I have two date picker controls(Start Date nd End Date) in my SharePoint Calendar list. And I need to calculate the Hour difference on the fly and show it in a text box.
    Can anybody help me to achieve this task using client side scripting?
    Thank You in Advance.
    Juli

    Hi sravankumar1107,
    According to your description, my understanding is that you want to figure the difference between start date and end date and then you want to place the value in a text box.
    Here is a code snippet for your referecnce:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
    </script>
    <script type="text/javascript">
    function initControl()
    var txtstartDate = $("#" + $("label:contains('Start Time Date')").attr("for")).val();
    var txtstartHour = $("#" + $("label:contains('Start Time Hours')").attr("for")).val();
    var txtstartMinute = $("#" + $("label:contains('Start Time Minutes')").attr("for")).val();
    var txtendDate = $("#" + $("label:contains('End Time Date')").attr("for")).val();
    var txtendHour = $("#" + $("label:contains('End Time Hours')").attr("for")).val();
    var txtendMinutes = $("#" + $("label:contains('End Time Minutes')").attr("for")).val();
    var starttime = new Date(txtstartDate +" "txtstartHour +":"txtstartMinute);
    var endtime = new Date(txtendDate +" "txtendHour +":"txtendMinutes);
    var diff = endtime - starttime;
    var diffSeconds = diff/1000;
    var HH = Math.floor(diffSeconds/3600);
    txtHour.val(HH);
    </script>
    More information for your reference:
    http://stackoverflow.com/questions/21844281/i-am-using-datetime-picker-and-want-that-my-start-and-end-date-must-have-differe
    http://blog.pentalogic.net/2009/09/setting-default-duration-for-new-calender-events/
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • Auto update people picker value with email id when we add username in another people picker field in sharepoint 2013 list using javascript

    hi friends
    i have to people picker fields
    pp1 and pp2
    pp1 represents username
    pp2 represents email id
    here i problem is if user enters name in pp1, pp2 has to update with email id of corresponding user in pp1 dynamically.
    using java script is there any solution for this.
    please help me

    Hope below will help
    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <script type="text/ecmascript" language="ecmascript">
    var user;
    var visitorsGroup;
    function runCode() {
    var clientContext = new SP.ClientContext();
    var groupCollection = clientContext.get_web().get_siteGroups();
    // Get the visitors group, assuming its ID is 4.
    visitorsGroup = groupCollection.getById(4);
    user = clientContext.get_web().get_currentUser();
    var userCollection = visitorsGroup.get_users();
    userCollection.addUser(user);
    clientContext.load(user);
    clientContext.load(visitorsGroup);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySucceeded() {
    alert(user.get_title() + " added to group " + visitorsGroup.get_title());
    function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    </script>
    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />
    </asp:Content>http://msdn.microsoft.com/en-us/library/office/jj246835%28v=office.15%29.aspxhttp://msdn.microsoft.com/en-us/library/office/jj920104%28v=office.15%29.aspxhttp://stackoverflow.com/questions/20981226/sharepoint-2013-get-current-user-javascripthttp://sharepoint.stackexchange.com/questions/31457/get-user-via-javascript-client-object-model

  • Converting an array to a list using javascript

    There are several methods that return arrays, which we all know express cannot handle. The IDM faq metions you can use a script tag to manipulate array data, but gives no example. I like this method because some methods I encounter preface the object name with the object type, and the data needs to be cleaned before use. I always like little snippits that can be reused, so I'm sharing this one.
    Here is how to convert an array to a list, assuming the array is captured in "stupidarray":
        <split>
          <script>
            var myarray = env.get('stupidarray');
            // Code to manipulate the array
            outputarray = myarray.join(",")
            // Other code to manipulate the string before output
            // i.e. Stripping out the object type tags!
            // outputarray.replace(/User:/g,"");
          </script>
          <s>,</s>
        </split>

    there is a waveset util class provided for this, please check API
    --sFred                                                                                                                                                                                       

  • Clearing the textfield using javascript

    Good day, How do I clear a textfield when their is an onchange event that happen to my select list using javascript?
    Edited by: Joe Smith on Mar 6, 2011 11:15 PM

    Hi jari, How about when I clone a row the first row will only be null, the rest will not change.. How will I do that?
    this is the code in cloning a row:
    var seq;
    function pad(n)
    var s = '0000' + n;
    return s.substr(s.length-4);
    function updateFields(f)
      var fields = document.getElementsByName(f);
      var j;
      if (fields.length > 0)
        for (j = 0; j < fields.length; j++)
          fields[j].id = f + "_" + pad(j+1);
    function updateInputs()
    updateFields("f01");
    updateFields("f02");
    updateFields("f03");
    updateFields("f04");
    }Edited by: Joe Smith on Mar 7, 2011 5:38 PM

  • Populate Select List from Checkboxes?

    How do I populate a Select List from a checkbox set's checked display values and submitted values?
    I'm guessing I need to parse the colon-delimited values, but I have no idea how to get the display values, or how to put all of that into the Select List.
    Any ideas?
    Cheers,
    Ben

    Hello,
    Every select list item can be based on LOV. You can read more about it in here - http://download-uk.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28550/bldapp.htm#CHDFGFHI
    If you are trying to populate a select list, using JavaScript, you can see a good example in here - http://htmldb.oracle.com/pls/otn/f?p=11933:37
    Hope this helps,
    Arie.

Maybe you are looking for

  • Preview in Web Browser stopped working

    Hello - I used to be able to preview my project in Web Browser but today for some reason after I click it, the window opens and it looks like it is generating but when it finishes the browser window does not open.  I can preview Project, Preview from

  • ICloud won't install on Windows 7 PC

    Down loaded iCloud, but won't load on recently new HP Desktop PC running Windows 7. Pop up window states: iCloud Control Panel There is a problem with this windows installer package. A program required for this installation to complete could not be r

  • Determining which PCA to use between new-GL and classic EC-PCA

    I tried to use 1kek to transfer AR and AP from FI to PCA but failed with message saying "Document Splitting is Activated". We are considering using PCA to make B/S and P/L of several business unit in a company. We are using SAP 6.0. After looking for

  • Adobe reader 9.4.0 requires Internet Explorer 6.0 or greater

    Hello, I have a user who has reported Adobe Reader was not installed on his PC, which we complete via GPO as default for all our computers, and has never been an issue (WinXP and Win7 (x64) ).  When attempting to install the reader manually, I receiv

  • How to add attribute to characteristic already in production system

    HI Guru's ,                  How to add a attribute to characteristic which already exist in production system. thanks in advance