Set values in ListBox with Javascript.

Hello.
I have a ListBox that can have multiple values (you can set this in Designer 7.1 by the way). I want to select 1, 2, x, values in this ListBox by script in Javascript. I can read these values like this:
var a = xfa.resolveNode ("ListBox1.value").nodes;
xfa.host.messageBox (a.item(0).value);
But how can I set the values?
Another question: Is it possible to get these values as an array or do I have to parse the value above to get the values?
/Per

DropDownList2.clearItems(); <br />DropDownList2.rawValue =""; <br />//Add the new ones with an indexed boundItem <br />var myIndex = this.boundItem(xfa.event.change); <br />var cities = new Array( <br />  new Array("New Orleans", "NYC", "L.A."), <br />  new Array("Paris", "Lyon", "Marcheilles"), <br />  new Array("London", "Liverpool", "Newcastle", "Manchester"), <br />  new Array("Tokyo", "Kyoto", "Hiroshima"), <br />  new Array("Bremen", "Hannover", "Hamburg", "Berlin")); <br />for (i=0;i<cities[myIndex].length;i++){ DropDownList2.addItem(cities[myIndex][i] , String(i)); } <br />/Ulf DTP-tjänst

Similar Messages

  • How to get real value from selectOneChoice with javascript?

    Hi,
    How to get real value from selectOneChoice with javascript? The event.getNewValue() only gets me the index of the selected item, not the value/title.
    JSF page:
    <af:resource type="javascript">
    function parseAddress(event)
    alert("new value: " + event.getNewValue());
    </af:resource>
    <af:selectOneChoice label="Location:" value="" id="soc4">
    <af:clientListener type="valueChange" method="parseAddress" />
    <f:selectItems value="#{Person.locations}" id="si7"/>
    </af:selectOneChoice>
    HTML :
    <option title="225 Broadway, New York, NY-10007" selected="" value="0">225 Broadway (Central Office)</option>
    <option title="90 Mark St., New York, NY-10007" value="1">90 Mark St. (Central Office)</option>
    Thanks a lot.

    Something I was missing ,
    You need to add valuePassThru="true" in your <af:selectOneChoice component. I have personally tested it and got the actual value in alert box. I hope this time you got the real solution. You can also test the following code by your end.
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1">
    <af:form id="f1">
    <af:panelBox text="PanelBox1" id="pb1">
    <af:selectOneChoice label="Set Log Level" id="soc1"
    value="#{SelectManagedBean.loggerDefault}"
    valuePassThru="true">
    <af:selectItem label="select one" value="First" id="s6"/>
    <af:selectItem label="select two" value="Second" id="s56"/>
    <af:clientListener method="setLogLevel" type="valueChange"/>
    </af:selectOneChoice>
    <af:resource type="javascript">
    function setLogLevel(evt) {
    var selectOneChoice = evt.getSource();
    var logLevel = selectOneChoice.getSubmittedValue();
    // var logLevelObject = AdfLogger.NONE;
    alert("new value is : " + logLevel);
    //alert(evt.getSelection);
    //alert(logLevelObject);
    evt.cancel();
    </af:resource>
    </af:panelBox>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>

  • Save the selected value from listbox with its respective tab control dropdown selcted values in another listbox

    Hi all,
    I am making a vi where I have to save the selected value from listbox with its respective tab control dropdown selcted values in another listbox.Whenever I select Item1 then the heading change and respective tab will open for that item.But Now I just want to save the selection and put it in another ListBox.SO that I can renmove or add according to my wish. Plz help me.
    Solved!
    Go to Solution.
    Attachments:
    my_vi.png ‏83 KB

    Hi, I successfully make the vi to insert itmes from listbox1 to listbox2.Whenever I select itmes 1 in listbox 1 it display same elected item in listbox2 , but it not appending the items in listbox2.Like If 1 is selected in listbox1 then 1 will display , next time after saving when I selct next item like 3 then in listbox 2, 1 is replaced by 3,it dont come in second row of listbox2.Hope I am able to explain.\
    Plz help me to resolve this.
    Attachments:
    listbox_update.vi ‏11 KB

  • XmlObject - set value of element with a particular attribute

    Hi,
    In a xmlObject I try to set the value of xml element with a particular attribute but it doesn't work
    //get value of element with a particular attribute
    var myValue = xmlObject.ELEMENTS.ELEMENT.(@category == "myCategory"))// works fine
    //set value of element with a particular attribute
    var myValue = "foo"
    xmlObject.ELEMENTS.ELEMENT.(@category == "myCategory"))= myValue // doesn't work
    Thanks for your help
    Regards

    Hi Dirk,
    For example :
    var xmlObject = new XML ( "<rootElement> <elements> <element category='foo1'>value1</element> <element category='foo2'>value2</element> <element category='foo3'>value3</element> </elements></rootElement>");
    myValue = xmlObject.elements.element.(@category == "foo1");
    $.writeln(myValue)// return value1
    // Now I want modify value1 to value99 like this
    xmlObject.elements.element.(@category == "foo1")= "value99"; //doesn't work
    I hope I was clear in my explanation ;-)
    Regards

  • Dynamically set y axis (position) with javascript

    Hello
    I wonder if it is possible with javascript to set a y position of flowed subform in non interactive adobe form?
    For example: For a certain subform  which is inclued in (flowed) main I want to be shown at certain vertical (y) position but only in the last page at bottom of main.
    Last page I can find with
    if(xfa.layout.page(this) == xfa.layout.pageCount())
    but when changing
    this.y = "100 mm"
    it doesn't changes subform position.
    I also tried with this.y = "100in", but result is the same.
    Does anybody now a solution?

    It's not a field, it's a complete subform with a table and some texts fields, which I want to show only in last page.
    I tried changing subform to a positioned already before and changing it's y axis in javascript (tried in all events) doesn't work.
    Could it be that syntax posted in first post isn't correct?
    In that case (positioned subform) I have blank space on all pages but last one. For example, if a complete layout of a page is 100%, main 70% and subform 30%, I get 30% of blank space on all pages before last one, which I would like to avoid, so that main would be 100% in every page but last one and in the last one main should be only 70% and subform 30%.

  • Set Default Values in Listbox with Dialog Programming

    Hi all,
    I am stuck with a problem i.e  I am working with Dialog Programming Screen
    where i have to set default values in some n numbers of Listbox which i have created on Screen.
    This default value is needed to be fetched from database table.
    I am using single table. Hence no confusion that i have to first fetch data from 1st listbox then corresponding data is fetched into second & so on ..NO NO This is not required.
    Simple one screen which will update a table in database, where  some fields on the screen needs to be default set as per tables domain default values set while table creation.
    Please help me out in this.
    Thanks & Regards,
    Sandhya.

    Please search SDN, before you post a new forum from next time... any ways just follow the below code..
    u need to use the FM 'VRM_SET_VALUES' to implement list box in module pool. Check the below code. u have to write this code in PBO..
    if c = 0.
    select land1 landx from t005t into table wi_country.
    sort wi_country by land1.
    delete adjacent duplicates from wi_country comparing all fields.
    loop at wi_country.
    wa_ctry-key = wi_country-land1.
    wa_ctry-text = wi_country-landx .
    append wa_ctry to wi_ctry.
    endloop.
    call function 'VRM_SET_VALUES'
    exporting
    id = 'ZCUST_MASTER1-COUNTRY'
    values = wi_ctry
    exceptions
    id_illegal_name = 1
    others = 2
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    c = 1.
    endif.
    Hope this helps u,
    Regards,
    Rajesh

  • Export values to listbox with the same format

    Dears,
    kindly i need some support please to solve this problem.
    I have a listbox that retrieve a data as per auto filter based on 3 criteria, but these data isn't retrieved with the same format, i retrieve these data from tow different tables, both of them exported with the default format,
    note: the table source is imported via "Existing connections" but the values format are processed at both of all, is this problem related to the data source or lixtbox options
    i uploaded the whole workbook, you can call the userform from sheet that called "Interface", and fill the 1 & 2 combobox with any inputs, and the last combobox you have to choose "Dec", then hit "Daily" or "Monthly"
    button
    Private Sub Daily_Click()
    Dim Source As Range, c As Range, i%, Aux As Worksheet
    Dim fa As Range, nc%, ca, v As Range, A As Worksheet, s$
    Me.ListBox1.ColumnCount = 11
    ListBox1.Clear
    Application.ScreenUpdating = True
    Set A = ThisWorkbook.Sheets("Daily")
    Set Aux = ThisWorkbook.Sheets("popup") ' auxiliary sheet
    Set Source = A.Range("A1:CB1")
    Set c = A.Range("a1").CurrentRegion
    Source.AutoFilter Field:=1, Criteria1:=Month_list.Value
    Source.AutoFilter Field:=4, Criteria1:=Leader_list.Value
    Source.AutoFilter Field:=6, Criteria1:=User_list.Value
    Set v = c.SpecialCells(xlCellTypeVisible) ' filtered range
    Aux.Cells.ClearContents
    v.Copy Aux.Range("a1")
    Set fa = Aux.Range("a1").CurrentRegion
    nc = fa.Columns.Count
    ca = Array(3, 13, 14, 15, 16, 17, 21, 30, 31, 32, 33) ' columns you want
    For i = LBound(ca) To UBound(ca)
    fa.Columns(ca(i)).Copy Aux.Cells(1, nc + 3 + i) ' create final range
    Next
    Me.ListBox1.List = Aux.Cells(1, nc + 2 + i).CurrentRegion.Value
    With Me.ListBox1
    Me.ListBox1.BoundColumn = 1
    Me.ListBox1.BorderStyle = fmBorderStyleSingle
    Me.ListBox1.ColumnHeads = True
    Me.ListBox1.BackColor = RGB(255, 255, 255)
    Me.ListBox1.ColumnWidths = "70; 75; 57; 80; 90; 150; 60; 80; 80; 80; 80; 70"
    Me.ListBox1.BorderStyle = 1
    Me.ListBox1.MultiSelect = fmMultiSelectExtended
    End With
    End Sub
         the workbook
    thanks a lot, 

    Either you need to reformat the values in memory as required before populating to the ListBox, or if the cells are formatted the way you want you can read the cell's text values, though not in one go as an an array.
    Based on a quick look of your code above try the following, but adapt if it's not quite right
    Set fa = Aux.Range("a1").CurrentRegion
    nc = fa.Columns.Count
    ca = Array(3, 10, 14, 16, 20, 21, 22, 23, 24) ' columns you want
    '' don't need this
    ' For i = LBound(ca) To UBound(ca)
    ' fa.Columns(ca(i)).Copy Aux.Cells(1, nc + 3 + i) ' create final range
    ' Next
    Dim lastRow As Long, j As Long ' put these up top
    ' after copying to Aux, but no need to
    lastRow = Aux.Range("a100000").End(xlUp).Row
    ReDim arr(1 To lastRow, LBound(ca) To UBound(ca))
    For i = LBound(ca) To UBound(ca)
    For j = 1 To lastRow
    arr(j, i) = Aux.Cells(j, ca(i)).Text
    Next
    Next
    Me.ListBox1.List = arr

  • Setting own security handler with JavaScript

    Hi,
    I build the security handler plugin example (SecurityHandler.api) and installed it. Then I wanted to set this handler via JavaScript to a document but I have no access to it. If I list all handlers (security.handlers) in a trusted function only the standard handler occur. If I change the security settings via Adobe I have the handler listed in the drop down box. I am using Acrobat 8 Professional.
    Many thanks for your advice in advance!
    Regards
    Jörg

    Ian,
    As a general statement, wireless networks are inherently insecure.
    "I have now switched off the broadcasting of the name.
    What level of security is this?
    If this is all you have done, roughly speaking, your network is just as
    (in)secure as it was when you plugged in the router.
    Do you have file or printer sharing turned on? Are your Mac firewalls
    stealthed and refusing UDP packets? Will the router accept any inbound
    request for an internet connection? Have you changed the default password
    on the router?
    The answers to these questions speak to the relative (in)security of your
    Macs.
    Is your son using any form of encryption, say, WEP, or, preferably, WPA?
    If not, your network is less secure.
    "We live in a quiet cul-de-sac where any strange people or cars would be noticed immediately, so we are probably not so vulnerable to wireless-hackers as others might be. Or am I living in a "fool's paradise"?"
    Yes, and here's why.
    "Does anyone know where I might be able to get hold of some reasonably simple, step by step instructions."
    I was going to suggest reading the router's manual, but it is pure and utter
    fertilizer. Looks as though a marketroid (who knows some buzzwords but
    not their meanings) patched that monstrosity together using the user
    menu storyboard walk-through and a lot buzzword-laden filler "lifted"
    from the Web.
    Would it be humanly possible to run an ethernet cable from your router to
    where your son computes and turn off the wireless?
    Since I don't own one, I can't help with a primer on securing it. Sorry.
    -Wayne

  • Set Email Description (body) with javascript

    I am trying to set the Email description in the OnLoad event of the email form in CRM 2011
    Using this code:
    "Xrm.Page.getAttribute("description").setValue(mailText.toString());"
    In OnLoad of the email form my script is excecuted every time it loads / refreshes the page but the description is sometimes shown and sometimes not.
    Does somebody know about this behavior and may have a solution?
    Greez

    Thx for your reply. The rest of the code is working. I debuged it about 1000 times. :)
    But here it is:
    function FillEmail()
    var lookup = new Array();
    regObj = Xrm.Page.getAttribute("regardingobjectid").getValue();
    if (regObj != null)
    if (regObj[0].entityType == "new_besuchsbericht")
    var bericht = CrmRestKit.Retrieve("new_besuchsbericht", regObj[0].id, [
    "new_name",
    "OwnerId",
    "new_OrtdesBesuchs",
    "new_AnsprechpersonId",
    "new_Besuchsdatumvon",
    "new_Besuchsdatumbis",
    "new_Teilnehmer",
    "new_Beschreibung"
    ], null);
    var thema = bericht.new_name;
    var owner = bericht.OwnerId;
    var ortDesBesuchs = bericht.new_OrtdesBesuchs;
    var ansprechperson = bericht.new_AnsprechpersonId;
    var besuchsdatumvon = bericht.new_Besuchsdatumvon;
    var besuchsdatumbis = bericht.new_Besuchsdatumbis;
    var teilnehmer = bericht.new_Teilnehmer;
    var beschreibung = bericht.new_Beschreibung;
    var ansprechName = "";
    if (ansprechperson.Name != null)
    ansprechName = ansprechperson.Name;
    var dateVon = new Date(parseInt(besuchsdatumvon.replace("/Date(", "").replace(")/", ""), 10)).toLocaleString();
    var dateBis = new Date(parseInt(besuchsdatumbis.replace("/Date(", "").replace(")/", ""), 10)).toLocaleString();
    var mailText = "<div style=\"font-family: Arial; font-size: 11pt;\">";
    mailText += "Thema: " + thema;
    mailText += "<br/><br/>";
    mailText += "Ort des Besuchs: " + ortDesBesuchs;
    mailText += "<br/><br/>";
    mailText += "Ansprechperson: " + ansprechName;
    mailText += "<br/><br/>";
    mailText += "Besuchsdatum von: " + dateVon;
    mailText += "<br/>";
    mailText += "Besuchsdatum bis: " + dateBis;
    mailText += "<br/><br/>";
    mailText += "Teilnehmer: " + teilnehmer;
    mailText += "<br/><br/>";
    mailText += "Beschreibung: <br/>";
    mailText += beschreibung;
    mailText += "</div>";
    Xrm.Page.getAttribute("subject").setValue(thema);
    var mailDescription = Xrm.Page.getAttribute("description");
    if (mailDescription != null)
    mailDescription.setValue(mailText.toString());
    alert("description set");
    The Subject is set every time and the "alert" in the end is fired after every load of the page.

  • Getting hidden value with javascript problem

    <html>
    <body>
    <form>
    <input type="hidden" id="code" value="123">
    </form>
    </html>
    when open the html file and type "javascript:alert(document.getElementById("code").value)" in the address bar, I get a message box with "123".
    but when i do in the jsp with
    <input type="hidden" id="code" value="<%=request.getParameter("code")%>">
    and type the javascript in the address bar, i get "object not supported".
    Can anyone tell me how to get hidden value in jsp with javascript?
    thank you.

    There is no difference between a JSP or plain html, since javascript executes on the client side after the JSP is done processing. There is obviously something wrong with the HTML content after you input the request value, so check the generated HTML in your browser to see if there are any unwanted quotes in there or something.

  • Setting User Preferences With Javascript In Acrobat X

    Hi All,
    Is there a way thru Javascript to programatically set a value in the User Preferences?
    I am trying to create a batch sequence that exports PDFs to HTMLs. In the Acrobat X preferences, there is a conversion option that sets the option of "Run OCR If Needed" to true or false.
    Edit --> Preferences --> Convert From PDF --> HTML --> Run OCR if needed (True|False)
    Depending on conditions, I need to programtically set the value of this preference during the batch sequence before I export the document to HTML. Is this possible? Any help would be greatly appreaciated.
    Thank you,
    Teri

    There are very few user preferences that can be controlled with JavaScript, and this isn't one of them.

  • Set Date With Javascript

    I have 2 date fields, A and B.
    What I need to do is once I tab out of A, I need to set B to A+1year-1day.
    I can do this in a page process on submit with
    ADD_MONTHS(:P_A, 12)-1
    but I need this to be done on change of field A.
    Any help appreciated
    Gus

    Hi Gus,
    you need to provide the date format you are using.
    Add this to your FIELD A "html form element attributes":
    onblur="javascript:fnc_field_b(this)"Add this to your page header:
    &lt;script>
    function fnc_field_b(v_field_a){
    /* Input: mm/dd/yyyy */
    /* Output: dd.mm.yyyy */
    /* Documentation: http://www.javascriptkata.com/2007/04/27/mastering-of-the-date-object-in-javascript/ */
    /*                http://programming.top54u.com/post/Javascript-Convert-String-to-Date.aspx            */
    /* Create date object */
    var myDate = new Date(v_field_a.value);
    /* Add 1 year */
    myDate.setDate(myDate.getDate() + 365);
    /* Create output string DD.MM.YYYY */
    /* Day */
    var myStr = (myDate.getDate() < 10 ? "0" + myDate.getDate().toString() : myDate.getDate().toString()) +  ".";
    /* Month */
        myStr = myStr + (myDate.getMonth()+1 < 10 ? "0" + (myDate.getMonth()+1).toString() : (myDate.getMonth()+1).toString()) + ".";
    /* Year */
        myStr = myStr + myDate.getFullYear().toString();
    /* Set value */
    $s('P1_FIELD_B',myStr);
    &lt;/script>Change the field P1_FIELD_B to the name of your field B name.
    Best regards,
    Tobias
    Edited by: Tobias Arnhold on Mar 7, 2011 4:44 PM

  • Change "choiseListe" values with javascript

    Dear,
    Is it possible to change "choiseListe"  values  with javascript.
    Exemple il have a choseListe :
         Country //// Values
          USA            us
          France         fr
          Spain           sp
    When il click in a botton i whant to change this choceListe :
         Country //// Values
          Morocco           ma
         Portugal           pt
    Thanks

    Hi,
    Listboxes and dropdowns can be scripted against without too much difficulty.
    You would need something like this in the click event of the button:
    listbox1.rawValue = null; //clear previous choice
    listbox1.clearItems(); //clear the list items
    listbox1.addItem("Moocco", "ma"); //add new list items
    listbox1.additem("Portugal", "pt");
    Hope that helps,
    Niall

  • Dynamic action with set value on date field

    Hi,
    I'm using APEX 4.02
    I'm trying to calculate the age based on the date of birth dynamically on a form. I'm trying to do this with a (advanced)dynamic action with set value.
    I'm able to get this kind of action working based on a number field etc, but NEVER on a date field.
    I've read all posts on this subject but so far no solution. Even if I try to simply copy the value over to another date field or typecast it to a string ( to_char function ) it does not work. So for me the problem seems to be in the source field being a date field.
    I've tried using the source value as is in a select statement :
    select :P33_GEBOORTEDATUM from dual;
    and also type casted based on the date format :
    select TO_DATE(:P33_GEBOORTEDATUM,'DD-MON-YYYY') from dual
    but still no luck.
    On the same form I don't have any issues as long as the calculation is based on number fields, but as soon as I start using dates all goes wrong.
    Any suggestions would be greatly appreciated. If you need any extra info just let me know.
    Cheers
    Bas
    b.t.w My application default date format is DD-MON-YYYY, maybe this has something to do with the issue .... ?
    Edited by: user3338841 on 3-apr-2011 7:33

    Hi,
    Create a dynamic action named "set age" with following values.
    Event: Change
    Selection Type: Item(s)
    Item(s): P1_DATE_OF_BIRTH
    Action: Set value
    Fire on page load: TRUE
    Set Type: PL/SQL Expression
    PL/SQL Expression: ROUND( (SYSDATE - :P1_DATE_OF_BIRTH)/365.24,0)
    Page items to submit: P1_DATE_OF_BIRTH
    Selection Type: Item(s)
    Item(s): P1_AGE
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • How to set values to the structure containing a node with cardinality 0..n

    Hello.
    I 'm trying to set values for the node with cardinality 0..n. The node type is "Fields".
    <xsd:complexType name="Field">
       <xsd:sequence>
          <xsd:element name="fieldCode" type="xsd:string"></xsd:element>
          <xsd:element name="displayValue" type="xsd:string" minOccurs="0"></xsd:element>
       </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Fields">
       <xsd:sequence>
          <xsd:element name="field" type="tns:Field" minOccurs="0" maxOccurs="unbounded"></xsd:element>
       </xsd:sequence>
    </xsd:complexType>
    I  need to set several values for the element "fieldCode" but it has cardinality 0..1 and BPM does not allow it but I did not find any option about how to set values for the structure of type "Fields". Could you help me?
    Best regards,
    Timur Semenchuk

    Hi Marcus,
    If there is no way you could change the cardinality of the node, and thus it can contain 0..n items, I think you should create-and-add a new element programmatically.
    Since the collection can contain zero elements, I would add a 'new' button, which upon clicking adds one new element via:
    IYourNodeElement yourNodeElem = wdContext.nodeYourNode().createYourNodeElement();
    wdContext.nodeYourNode().addElement(yourNodeElem);
    Hope this explains a bit!
    Best,
    Robin van het Hof

Maybe you are looking for