Append variable and array items after a record array search

I would like to update a variable and array item after a record array search, and wanted to know what would be the best way of carrying it out in Javascript.
In this case, if a match is found between the variable and area item, then the postcode item should be appended to the variable.
The same needs to be done for the array items, but I reckon that a for loop would work best in this scenario, as each individual item would need to be accessed somehow.
Btw due to the nature of my program, there will always be a match. Furthermore, I need to be able to distinguish between the singleAddress and multipleAddresses variables.
Hopefully this code explains things better:
// before search
var singleAddress = "Mount Farm";
var multipleAddresses = ["Elfield Park", "Far Bletchley", "Medbourne", "Brickfields"];
// this is the record which the search needs to be run against
plot = [{
postcode: "MK1",
area: "Denbigh, Mount Farm",
postcode: "MK2",
area: "Brickfields, Central Bletchley, Fenny Stratford, Water Eaton"
postcode: "MK3",
area: "Church Green, Far Bletchley, Old Bletchley, West Bletchley",
postcode: "MK4",
area: "Emerson Valley, Furzton, Kingsmead, Shenley Brook End, Snelshall West, Tattenhoe, Tattenhoe Park, Westcroft, Whaddon, Woodhill",
postcode: "MK5",
area: "Crownhill, Elfield Park, Grange Farm, Oakhill, Knowlhill, Loughton, Medbourne, Shenley Brook End, Shenley Church End, Shenley Lodge, Shenley Wood",
// after search is run then:
// var singleAddress = "Mount Farm, MK1"
// var multipleAddresses = ["Elfield Park, MK5", "Far Bletchley, MK3", "Medbourne, MK5", "Brickfields, MK2"]
Fiddle here

I would like to update a variable and array item after a record array search, and wanted to know what would be the best way of carrying it out in Javascript.
In this case, if a match is found between the variable and area item, then the postcode item should be appended to the variable.
The same needs to be done for the array items, but I reckon that a for loop would work best in this scenario, as each individual item would need to be accessed somehow.
Btw due to the nature of my program, there will always be a match. Furthermore, I need to be able to distinguish between the singleAddress and multipleAddresses variables.
Hopefully this code explains things better:
// before search
var singleAddress = "Mount Farm";
var multipleAddresses = ["Elfield Park", "Far Bletchley", "Medbourne", "Brickfields"];
// this is the record which the search needs to be run against
plot = [{
postcode: "MK1",
area: "Denbigh, Mount Farm",
postcode: "MK2",
area: "Brickfields, Central Bletchley, Fenny Stratford, Water Eaton"
postcode: "MK3",
area: "Church Green, Far Bletchley, Old Bletchley, West Bletchley",
postcode: "MK4",
area: "Emerson Valley, Furzton, Kingsmead, Shenley Brook End, Snelshall West, Tattenhoe, Tattenhoe Park, Westcroft, Whaddon, Woodhill",
postcode: "MK5",
area: "Crownhill, Elfield Park, Grange Farm, Oakhill, Knowlhill, Loughton, Medbourne, Shenley Brook End, Shenley Church End, Shenley Lodge, Shenley Wood",
// after search is run then:
// var singleAddress = "Mount Farm, MK1"
// var multipleAddresses = ["Elfield Park, MK5", "Far Bletchley, MK3", "Medbourne, MK5", "Brickfields, MK2"]
Fiddle here

Similar Messages

  • How to find and modify  item in a nested array collection?

    Hi,
    would anybody know how to find and modify item in a nested
    array collection:
    private var ac:ArrayCollection = new ArrayCollection([
    {id:1,name:"A",children:[{id:4,name:"AA",children:[{id:8,name:"AAA"}]},{id:5,name:"AB"}]} ,
    {id:2,name:"B",children:[{id:6,name:"BA"},{id:7,name:"BB"}]},
    {id:3,name:"C"}
    Let's say I've got object {id:8, name:"X"} , how could I find
    item in a collection with the correspoding id property, get handle
    on it and update the name property of that object?
    I'm trying to use this as a dataprovider for a tree populated
    via CF and remoting....
    Thanks a lot for help!

    Thanks a lot for your help!
    In the meantime I've come up with a recursive version of the
    code.
    This works and replaces the item on any level deep:
    private function findInAC(ac:ArrayCollection):void{
    var iMatchValue:uint=8;
    for(var i:uint=0; i<ac.length; i++){
    if(ac
    .id == iMatchValue){
    ac.name = "NEW NAME";
    break;
    if(ac
    .children !=undefined){
    findInAC( new ArrayCollection(ac.children));
    However, if I use the array collection as a dataprovider for
    a tree and change it, the tree doesn't update, unless I collapse
    and reopen it.
    Any ideas how to fix it ?

  • How update Fund Center and Commitment Item after posting

    hi Experts,
    Funds management was activated during the year and hence there are few open items saved without capturing Fund Center and Commitment Item. When i tried to clear these open item i get the following error
    Line  in document xxx xxxxxxxxxxxx   does not contain any commitment items
    Is there any program which i can use to update derivation to the already posted line item
    Thanks in Advance

    Hi,
    Solutions proposed by Alexey are good if FM document was created for the FI documents in question. If, however, no FM document was created, reassignment process won't help. You can try FMN0 transaction after creating a derivation rule in FMDERIVE for these documents, but I cannot confirm that it would be sucessful as FMN0 transaction is not perfect.
    The solution could be updating FI tables (BSEG/BSIS/BSAS) with FM assignment (fund centre/commitment item) and only then running FMN0 transaction. In this case, FM document will be created and you'll be able to process the items.
    Regards,
    Eli

  • I can't see the button and text item, After compile...

    I bring a form source at the another ERP application.
    and compile it at the our ERP application.
    There is no problem at compiling file...
    comfile succesfully complete...
    but There is no text item and button when i execute program...
    What is the problem --; Help me ~~

    at oracle E-Business Suite
    We add-on a form program
    and i execute the program to use program.
    but there is no button and text item at form. ^^

  • Add and remove items by comparing 2 arrays

    I have two arrays of objects. Each object has a unique name property besides few others. One of the array is a local copy and the other one is sent from server after regular intervals. The local copy of arrays is then used to add a movieclips into a container.
    Now, I want that when I receive an array from the server, I compare it with the one which is already with me locally such that the items which were not in the received array but were there in the local array, get removed from the container and the newly added ones only get added. The items which were present in both local and remote array remain as it is. how can i do this?

    I may be missing something, but it doesn't sound like you need to compare anything, you just need to replace the local array with the newly received one.
    local array = 1,2,3,4,5
    new array  3,4,5,6,7
    Based on what you described you would get rid of 1 and 2 and use 3,4,5.  I am assuming you would use the new ones that came from the server, so you essentially end up using 3,4,5,6,7
    So you should just need to go thru the new array and if something in the container is not in the new array then remove it.

  • No File Name on Chat, and Small Item after forward...

    Hi Skype Friends, 
    i have updated my Skype earlier and i have been hard time about these updates.. 
    i am familiar and more satisfied regarding the un-updated skype since it is user friendly.
    Thus, 
     There is no data file on your chat box regarding what name of that file was send to you, only picture and will give you much time clicking it to view the item sent to you.
    If you forward a picture/file you received to a friend, the picture becomes smaller and it is not readable.
    i wanted to uninstall the update, but i cant, maybe you can help me regarding this issue,..
    Thanks and more power skype family.
    Solved!
    Go to Solution.
    Attachments:
    Untitled.png ‏196 KB
    small.png ‏253 KB

    This thread contains instructions on downgrading to the previous version:
    http://community.skype.com/t5/Windows-desktop-client/How-to-Update-or-revert-from-6-22-to-other-vers...
    Sean Ellis - uses Skype chat for serious work
    Click here to read my blog post on Skype 7 and basic principles of GUI design

  • Lost albums and triple items after archive & install

    Hopefully, I can write this so it is understandable.
    First of all, I had a similar problem to some I have read here when I transferred my photos from my old G4 to my new imac, I found I had lots of those nasty grey boxes with the question marks. I did find that the originals were there, just in another roll but it happened to many different photos with no apparent connection. But.....I recently had a problem with my new imac and we had to do an archive and install...
    Well, now I no longer have the grey boxes...(at least I don't think so) but I lost all my albums and I now have 30,500 items when I originally had only 10,000. (that is why I am not sure about the grey boxes, because I have not been able to open every photo)
    It appears that I have all the originals, the modified, and the thumbnails showing up in the main library. I have iphoto library manager and when I open the only other library thru photo manager, it retained the albums in that one!!!
    My concern is that I don't want to go in and start deleting photos and somehow screw up the whole library. I can always redo the albums, that is not the biggest problem. But 30,500 items to go through???? Not sure what to do next.
    I hope this makes sense....
    Thanks Judy

    Hi Jamiemojo!
    " ...why won't my system allow me to change the name of my main user account, the one with that house icon?"
    Although not recommended, it can be changed, but as you have seen, there are consequences if not done correctly.
    Recover from renaming your Home folder
    Mac OS X 10.3: Return to Default Desktop, Apparent "Loss" of Home Directory
    Mac OS X 10.3 Help: My home folder and desktop are different than before
    Here is Apple's method How to change user short name or home directory name.
    But here's a Much Easier Process.
    Good Luck!
    ali b

  • Checksum error for Hidden and Protected item

    I have a region with 3 items - a Text field, a Text area and a Hidden and Protected item. When clicking on the save button the record should be written to the table. However I get the following error:
    ++Checksum error for Hidden and Protected item ID (7676217916943303), value (), posted checksum (1060941776BCEA7DDAE813A442DF01E3), expected checksum (********************************), index_i (8), index_j (1), index_m (3);++
    When I change the hidden and protected field to a regular text field I am able to successfully process the page.
    Do I have to do anything different when I have a hidden and protected field? Would appreciate any suggestions/comments to help resolve this issue.
    Regards,
    Ghazi

    If you have client-side code that changes the value of a "Hidden and Protected" item after the item/value has been emitted to the page by Application Express, you need to change the item type to Hidden, instead.
    Scott

  • Line Item: After reading all your links and discussions

    From the links and the discussions I was referred to in a previous post, please correct me if I am wrong. I understood that with if a characteristic is going to have several values (defined in that case as "has cardinality"), then it is better to make that characteristic a line item.
    It has some advantages as a result of the fact that the line item dimension has no dimension table but only SID table.
    1--Does this make loading data faster Or, running queries faster?
    2--I also read that "line dimension on means that this dimension becomes part of fact table", can you explain this?
    3--Some of the experts said you create line item when the characteristics in the dimension is 20 or 30 % that of the fact table. Is this 20 or 30? And, are we comparing all the characteristics in all the dimensions in the Cube or just the one dimension which we want to make the line item?
    4--Also, I get the 20 or 30% of the Dimension but what it being compared to in the Fact Table?
    5--I didn't get the cardinality stuff well so any hints other than links will help.
    6--Finally, won't this easily make the designer run out of the 13 (16-3 reserved) available dimensions?
    7--If the Rule of thumb is dimension table size should be smaller than fact table, and line item dimensions makes this possible, isn't it in the same token killing the ratio of 16 dimension to 1 Fact table in a cube?
    8--Is this a consideration after data has been loaded into Cubes or during the design phase of the Cube?
    9--If this consideration is applicable only when there is data then how can you factor this into your design? How to wait until you are in trouble to fix the problem?
    Thanks

    HI Caud,
    1] Query reading performance will be improved. As it can access only Master data table and Fact table.
    Setting it as a Line Item dim also causes a b-tree index to be built instead of a bitmap index, but also embeds SID directly in the fact table, eliminating the dimension table.
    2] Line item Diemsion- when ever ur Dimension table contains a single Char then it is better to join ur master data table with the Fact table. So there will be connection with SID.
    3]U chooses the line item when ever there is a high cardinality. i.e if ur DIM table is 10%of Fact table then u will go with the Line item Dim.
    the percentage is w.r.t the number of records.
    4] its total number of records.
    5]Cardinality creates indexes on the Dimension table entries and there by you would see an improvement in performance.
    With Cardinality, you can assign a Dimension containing Multiple Characteristics
    6] It depends based ur business requirement and the type of data that u use.
    8] It is before loading into the cube.
    9]it is better to design at the initial stage it self.
    Refer this link..
    http://help.sap.com/saphelp_nw04/helpdata/en/a7/d50f395fc8cb7fe10000000a11402f/frameset.htm
    Regards-
    MM
    Assign points if it helps.
    It is better to assign points to all who ever replies to u. As they spent lot of time on these Threads.
    Message was edited by: vishnuC

  • Acrobat v9 JavaScript Alert Box - any way to add space or line break after each array item?

    I have a Document level Javascript used to identify blank required fields and is triggered on document actions, Print and Save. The script identifies the blank required fields, counts them, and outputs to an Alert box indicating the number of required fields blank and lists the fields by tooltip name. The script identifies the required fields by an asterisk at the end of each tool tip.
    My question is there any way to add a space or a line break after the comma for each listed item?
    Here is an image of the output where the listed items are all run together.
    Here is the code:
    function validateFields()
    //a counter for the number of empty fields
    var flg = 0
    // count all the form fields
    var n = this.numFields
    //create an array to contain the names of required fields
    //if they are determined to be empty
    var fArr = new Array();
    //loop through all fields and check for those that are required
    // all fields that have a '*' in their tool tip are required
    for(var i = 0;i<n;i++){
    var fn = this.getNthFieldName(i);
    var f = this.getField(fn);
    //tool tip is the fields\'s 'userName' property;
    var tt = f.userName
    //test for the '*';
    if(tt.indexOf('*')!=-1 && f.value == f.defaultValue){
    //increment the counter of empty fields;
    flg++;
    //add the fields userName (tool tip) to the list of empty field names;
    fArr[fArr.length] = tt;
    //now display a message if there are empty fields
    if(flg>0){
    app.alert('There are '+flg+' fields that require a value\n\n'+ fArr,3)
    else{
    this.print();

    Thank you! The alert box array items now have a line break, image below.  You know you have made my day and possibly several weeks as now I have more understanding about how to apply everything I have been reading in the Acrobat JavaScript guide and of course as soon as you pointed out using a "join", that triggered some old-days of working with Access and SQL queries.
    I will work on the required attribute to see how I might reference it.  I am laughing at myself now - good luck to me in figuring it out as I was very stick-in-the-mud regarding the line break issue.
    Thanks again and here is the result of the updated code:

  • Trouble with Arrays of Menus and Menu Items

    Okay the short story is I am designing a GUI for an application, it has a lot of menus, and a lot of menu items per menu.
    I thought like in normal Java I could simply make an array of Menus and several arrays of menu items. My problem is that it compiles fine, but spews tons of exceptions. I am using Netbeans as my IDE.
    Here is a sample of my code. Its not the whole thing, but its the part that I suspect has problems since it worked before I switched to doing them as arrays.
    Menu [] menus = new Menu [11];
    menus[0].setText("File");
    MenuItem [] file = new MenuItem [8]; //FILE MENU DEFINITIONS
    file[2].setText("Open"); //open
    file[2].setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent arg0) {
    FileChooser fc = new FileChooser();
    File file =fc.showOpenDialog(primaryStage);
    // file[2].setAccelerator(null);
    menus[0].getItems().addAll(file);
    MenuBar menubar = MenuBarBuilder.create()
    .build();
    menubar.getMenus().addAll(menus);
    VBox vbox1 = VBoxBuilder.create()
    .children(menubar,scrollPane1,btn)
    .build();
    ap.getChildren().addAll(vbox1);
    Anyways the stuff compiles just fine no errors. But Netbeans spews exceptions like a guy who chugged a bottle of ipecac and the programs bombs.
    Here is some of them.
    Exception in Application start method
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:601)
         at com.javafx.main.Main.launchApp(Main.java:642)
         at com.javafx.main.Main.main(Main.java:805)
    Caused by: java.lang.RuntimeException: Exception in Application start method
         at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
         at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
         at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
         at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.NullPointerException
         at javafxapplication2.JavaFXApplication2.start(JavaFXApplication2.java:37)
         at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
         at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
         at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
         at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
         at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
         at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
         ... 1 more
    Java Result: 1
    I am not really sure what to do. I would like some recommendations.
    If possible I would still like to use arrays of Menus and Menu Items, but if its not possible, I would like to know and understand why not.

    I apologize if I don't fully understand. I am still kind new to this. But It was my understanding that .jar file was made after compiling not before. I am not really sure what you mean by class path. Could you give an example. Again this code worked wonderfully before I used arrays. If I comment it out and replace it with dummy code like this it compiles and runs just fine.
    MenuItem open = new MenuItem("TEST");
    Menu debug =new Menu("DEBUG");
    debug.getItems().add(open);
    MenuBar menubar = MenuBarBuilder.create()
    .build();
    menubar.getMenus().addAll(debug);
    StackPane rootz = new StackPane();
    final TextArea textArea =TextAreaBuilder.create()
    .prefWidth(600)
    .prefHeight(400)
    .wrapText(true)
    .build();
    ScrollPane scrollPane1 = new ScrollPane();
    scrollPane1.getStyleClass().add("no-border-scroll-pane");
    scrollPane1.setMinSize(400, 400);
    scrollPane1.setContent(textArea);
    VBox vbox1 = VBoxBuilder.create()
    .children(menubar,scrollPane1,btn)
    .build();
    ap.getChildren().addAll(vbox1);
    btn.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent arg0) {
    System.out.println("Hello World!");
    FileChooser fc = new FileChooser();
    File file =fc.showOpenDialog(primaryStage);
    Scene scene = new Scene(ap, 760, 500);
    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
    * The main() method is ignored in correctly deployed JavaFX application.
    * main() serves only as fallback in case the application can not be
    * launched through deployment artifacts, e.g., in IDEs with limited FX
    * support. NetBeans ignores main().
    * @param args the command line arguments
    public static void main(String[] args) {
    launch(args);
    }

  • GL Custom Reports not displaying source and line item Data after Upgrade

    Hi,
    I am having this issue even though General Ledger Journal Entry Summarization is set to "No Summarization" and in SLA the Line Type is set in detail for Transfer to GL. Have you come accross a specfic example like this? Can you please guide me to what the problem may be?
    None of the GL reports is showing the Source and Line Item details.
    Thanks,
    Arun

    I am having this issue even though General Ledger Journal Entry Summarization is set to "No Summarization" and in SLA the Line Type is set in detail for Transfer to GL. Have you come accross a specfic example like this? Can you please guide me to what the problem may be?
    None of the GL reports is showing the Source and Line Item details.Have you verified the queries of those reports after the upgrade? And, when you say upgrade, do you mean from 11i to R12?
    Did you set the application context properly?
    How to set the Organization Context in R12? [ID 437119.1]
    Oracle Applications Multiple Organizations Access Control for Custom Code [ID 420787.1]
    SQL Queries and Multi-Org Architecture in Release 12 [ID 462383.1]
    Setting APPS Context is mandatory step while loading data using public APIs [ID 473615.1]
    Thanks,
    Hussein

  • After Effects & Premiere Pro CS4 users: Turn off "Make text and other items larger or smaller" (Win)

    I just made a brief blog post recommending that After Effects CS4 and Premiere Pro CS4 users turn off the "Make text and other items larger or smaller" setting in Windows 7, since it causes some problems.
    Please use this thread to let us know whether this solved a problem for you or whether there are any problems with this solution.

    There isn't really an option to "turn off" the feature. Do you mean to say that it should be set to "Smaller - 100% (default)"?

  • Passing array variables into functions (and why I'm hopeless at arrays)

    OK, I have spent a day on this now and have done some fairly
    extensive searching online. The problem is - I am hopeless with
    arrays (and probably just actionscript generally for that matter)
    I want to create an array of buttons, so I set up an array of
    actions, step through each item and then try to pass that array
    action into an onclick button for an attached button
    The problem I have is that the onclick function ALWAYS
    returns the last item in the array.
    Help!
    Code below:
    ----------------------------------------------------------------

    the reason for this, is that once the for loop executes, the
    'last' value is the only one remaining. what one needs to do here
    is 'store' the string in a newly created property on each button,
    like this:

  • How do i add array element after acquiring 8 samples from pulsatile signals and display it?

    Hello, LabVIEW Experts,
    I'd like to do the following with the attached VI:
    1)enter raw data(sampling frequency 333K/sec and 333K samples) into array1
    2)the rising edge of the pusatile input triggers/starts the analog input(the first 8 points)
    3)the 8 data points are appended/inserted into array2
    4)front panel displays array and waveform of both array1 and array2
    I know what to do in other langauges but i am having a hard time doing it with LabVIEW.
    Please advise.
    Thank you.
    CK
    Attachments:
    tim continuation 020206.vi ‏90 KB

    Hi CK-
    The easiest method I can think of to perform this function is to sort through the array of data as it comes in and pull the necessary points.  I have attached a short example that shows how to graph the raw data and also to check two conditions:
    Checking through the array, always check to see if one element in the array is greater than the previous (using shift register to store data)
    Checking each point, always check to see if it exceeds the "Trigger Lvl" value
    If both of these conditions are met (hence the AND "gate"), we break the While loop and save the iteration value.  We then grab values from the original array starting at this index and take "Length" number of elements.  Finally we present the array subset similarly to the original data.  This example uses a simulated square wave with noise, but reading an array from your DAQ operation should allow you to achieve the same results.
    Hopefully this helps-
    Tom W
    National Instruments
    Attachments:
    Subset Suggestion.vi ‏79 KB

Maybe you are looking for

  • Win 7 Pro error R6034 after itunes 11.4

    I just installed itunes 11.4 on my Win 7 Pro system, which has all patches up to date.  After installing, all itunes services and itunes itself get the following error: application has made an attempt to load the C runtime library incorrectly.  (I *d

  • Change apple id in ios 5

    I just updated my Iphone 3GS with IOS 5 and need to change my apple ID from the one I initially loaded.  I can not find a setting anywhere to change the apple id on the phone.  I was going to restore the phone to original settings but was hoping for

  • Convert SQL statements to JAVA Code ?

    Using SQL queries Can I convert SQL statements to JAVA Code ? Edited by: user11238895 on Jun 7, 2009 10:54 PM Edited by: user11238895 on Jun 7, 2009 11:12 PM

  • Update Image field throughout PDF

    Hello, I have a 3 page pdf with an image field on each page. I would like to pick an image for the first page image field and then have the other two pages image fields display the same image I choose for the first page. Possible?

  • Error in enhanced receiver determination

    Hi Experts, I am trying to implement a scenario in which  i have to get the receivers at run time by doing a  lookup to a file which stores the destinations. i am getting the error that no receivers could be determined. thanks, Anika