Script seems to pause each time a value is commited

I created a simple script for copying the values of line "EVEN" to line "i" inside a button
var i = event.target.name.charAt(event.target.name.length-1);
this.getField("OPE003."+i+".NOCIVIQUE").value = this.getField("OPE003.EVEN.NOCIVIQUE").value;
this.getField("OPE003."+i+".TYPE.RUE").value = this.getField("OPE003.EVEN.TYPE.RUE").value;
this.getField("OPE003."+i+".RUE").value = this.getField("OPE003.EVEN.RUE").value;
this.getField("OPE003."+i+".APP").value = this.getField("OPE003.EVEN.APP").value;
this.getField("OPE003."+i+".ARRONDISSEMENT").value = this.getField("OPE003.EVEN.ARR").value;
this.getField("OPE003."+i+".CP").value = this.getField("OPE003.EVEN.CP").value;
the strange behavior is that instead of copying all the values at the same time, it copies only the first field.  if I press again, it copies the second one, on so on.
I tryied my button in an earlier version of the same document and it works great.  Now I think the only difference between the earlier and new version is I introduced a bunch of keystroke and validation scripts testing regular expressions when entering data in some fields that are not even those listed above.  There is no error in the console window and every value is transfered one after the other if I press the button 6 times.
What line of code have I possibly introduced that can stop such a simple button from working?

All variables declared outside of a function or used without declaring them first have document-wide scope. Since your code apparently triggers code in a different field that used the same variable name, there was a conflict. Changing the variable names is one approach, but it can be difficult to manage and it is much better to explicitly limit the scope of variables to only what is necessary. Normally you'd do this by placing as much code as you can into document-level JavaScripts as functions that get called in field events. But another way to do this is to place the code in field events inside anonymous functions that call themselves when the field script is triggered, something like:
// Place the code in an anonymous function and call it when this script is triggered.
(function () {
    var i = event.target.name.charAt(event.target.name.length-1);
    this.getField("OPE003."+i+".NOCIVIQUE").value = this.getField("OPE003.EVEN.NOCIVIQUE").value;
    this.getField("OPE003."+i+".TYPE.RUE").value = this.getField("OPE003.EVEN.TYPE.RUE").value;
    this.getField("OPE003."+i+".RUE").value = this.getField("OPE003.EVEN.RUE").value;
    this.getField("OPE003."+i+".APP").value = this.getField("OPE003.EVEN.APP").value;
    this.getField("OPE003."+i+".ARRONDISSEMENT").value = this.getField("OPE003.EVEN.ARR").value;
    this.getField("OPE003."+i+".CP").value = this.getField("OPE003.EVEN.CP").value;
If any of this code causes a script in another field that uses the same variable name to get triggered, then there won't be any conflict since the scope of the variables is local to the functions they are declared in.
This is convenient if you don't want to bother creating a named function in a document JavaScript and is in a form that is easy to convert to a named function if you ever want to. The code inside the function will work unchanged, you just have to slightly modify the first and last lines.

Similar Messages

  • I have a ASCII input feeding a value in. Each time this value falls between two numbers I want to increase the count by 1. How can I do this?

    I have been trying to work this out an I am sure is is not too difficult to do, but I cant seem to get anywhere with it. If anyone could help that would be great.
    Thanks
    RossH

    I am not currently at a PC with LabVIEW on, so Ic ant send you an example of how to do this. Instead you'll have to understand my description....
    I'll assume that you want to constantly monitor the input value...
    Use a while loop with a shift register to store the count value. You can initialise the count value to zero (or whatever you like) by wiring a numeric constant to it - to the left of the shift register - outside the loop. Place a case structure inside the loop and wire the shift register left to right through the false case. In the true case place the increment function and connect it between the input and output nodes you now have on the case structure. On each iteration of the loop the count value will either remain the same or be incremented b
    y one depending on whats wired to the boolean input on the case structure. Now you need to detect whether your ascii value is in range. You can use the 'In range and coerce' function for this (found in the comparison function pallette). Wire the range values and the input value to it and take the boolean output to the input of the case structure. The ascii value must be acquired within the loop, so that you are checking the updated value on each iteration (or if it comes via an array you could wire the array directly to the outside of the loop and enable indexing - in this case it would be best to use a for loop). You can place an indicator on the 'count' wire to monitor its value if you wish. Remember to also place some conditional statement to stop the loop when required and also a wait function should exist inside the loop. When the loop stops, the count value will be available at the output of the shift register.
    Hope this helps and is clear enough for you to implement?!

  • Add point to scatter plot each time a button is pressed

    Hi folks,
    Apologies if this has been answered elsewhere, I am new to LabVIEW and trying to get an experiment up-and-running quickly!
    I was wondering if anybody would have general pointers or code examples on how to create a 2D scatter plot, to which a data point is added each time a button is pressed.
    I am measuring a gauge pressure and a force (from a load cell). I would like the scatter plot to add another data point each time I press a button, so that a history of my datapoints is shown. It would also be quite nice is this plot could then be exported as a .jpg using another button, but this is not critical. 
    A seperate button would also be available to clear the scatter plot.
    My current thinking is that this can be done by 'adding to an array', - presumably the chart would refresh each time an element was added to the array, but I am struggling a little bit with how to do this.
    If anybody has any suggestions, I would be very grateful for them.
    Many thanks,
    Euan

    Hi Euan,
    If you want to have your data shown in real time (and I'm assuming you do) then you'll need to use a Waveform Chart. The chart is able to update itself each time a value is written to it.
    The event structure is your friend here: you can write a case to update the chart each time a button is pressed. You can also create cases for the other situations you mentioned (clear chart, export jpg etc.)
    If you don't care about the chart updating in real time then you can use your idea of updating an array and then use a Waveform Graph to plot the datapoints at the end of your program.
    Take a look at the LabVIEW Basics course and the Examples for info on how to implement the event structure. If you run into any problems just post your VI and we'll see if we can't help you fix them.
    -CC
    "If anyone needs me, I'll be in the Angry Dome!"

  • I want to use the Menu Bar each time. But every time I open Firefox I have to again open options and select Menu Bar. Can I get it to open each time?

    Sometimes it will already have the menu bar and sometimes it won't. It does not seem to remember each time that I want to use the Menu Bar.

    Hello DRAnderson100, try to delete the [http://kb.mozillazine.org/Localstore.rdf localstore.rdf] in [http://kb.mozillazine.org/Profile_folder_-_Firefox profile folder] and check it again.
    see for more info : [http://kb.mozillazine.org/Corrupt_localstore.rdf Corrupt localstore.rdf]
    thank you

  • HT5278 MY 1st gen iPad has candy crush ---but it is stuck in "an update mode". My iPad can no longer acceptsupdates for any games beyond 5.1. Therefore, each time I try to access the game it goes into a "pause" mode. I would hate to delete the game becaus

    MY 1st gen iPad has candy crush ---but it is stuck in "an update mode". My iPad can no longer acceptsupdates for any games beyond 5.1. Therefore, each time I try to access the game it goes into a "pause" mode. I would hate to delete the game because I think I will lose my score. But I can't play the game either.  Can someone help me with this?  Can I go back to my last updated candy crush for my ipad, or do I have to delete it and start over?  Also, how would I get the one for my generation iPad

    I have a similar problem. But my iPad shows the connect iTunes screen and gives error 2001 when I try to restore it.
    My iPad's battery was fine but I didn't use it for like 2 weeks. It's battery would've discharged and it turned off. When I tried to charge through wall socket, it got into the restart loop where it would show apple logo and turn off. So I did the simultaneous holding of Home and Sleep buttons for 10 seconds or more. It started showing connect to iTunes.
    When I try to restore, the iTunes does the usual "extracting file" or something and go upto preparing for restore. But the iPad screen turns off from "connect to iTunes" and iTunes gives the error 2001, and the screen is back to connect to iTunes.
    Also, if I don't plug in, the iPad seems dead, doesn't wake up or anything.

  • Key figure values vary each time the report is run by different users

    Hi All,
    We are facing a unique problem, here it goes :
    Different users are getting different values for the same key figure, when executing the same query  on the same selection conditions.Each time, user executes the report, he is getting varying values for the same key figure.Any idea's how to resolve this issue??
    Thanks in Advance
    Bindu

    Hi Bindu,
    One reason might be due to authorizations as discussed earlier.
    check how frequently is the cube getting refreshed.
    This might also happen that if users are running the data at different times and there is a cube load in between.
    check for this.
    Cheers,
    Srinath.

  • Is there a way to switch between workspaces in Spaces from the command line?  I want to write a script to set up certain applications in certain workspaces (without having to do it manually each time)...

    Is there a way to switch between workspaces in Spaces from the comnand line?  I use several workspaces from Spaces, each workspace having a certain number of fixed applications running.  Rather than set all this up each time I log on, I'd like to write a script from the command line (I use gawk) to automate this. Currently I have a gawk script that, given a directory, opens a few xterms whose working directory is the given directory, and opens "preview" applied to a certain file in that directory.  However, at present I have to manually move an xterm through each workspace and run my gawk script in each workspace (applied to each directory that I'm working on).
    There must be a better way...

    Addendum: Can this be done via:   open -a Spaces --args xxx  , where xxx is some set of arguments (or something like this)?

  • Is it possible to run a script each time a .CSV file is updated?

    I am having trouble with a script I am trying to write, which is made up of two parts:
    A .CSV file generated by PHP/MySQL whenever an RSS feed is updated. The contents of the .CSV are overwritten each time the PHP runs.
    A DataMerge script, written in JavaScript.
    What I would like to do is run the DataMerge script each time the .CSV file is updated. Is this possible, perhaps using an Event Listener within the PHP to trigger the DataMerge script? Or am I approaching this in the wrong way? I'm grateful for any thoughts you might have. Thanks, F.H.

    I would use Rorohiko's APID ToolKit: http://www.rorohiko.com/wordpress/indesign-downloads/active-page-item-developer/
    It has fileChanged event that is sent after the observed external file has changed.
    sorry guys for "labouring the point", but I'm working on very advanced project - and I need to know what my tool can or can't do
    and in this case - using APID will break point 2.3 of EULA, right ? interaction with external datasource - without user action ?
    robin
    www.adobescripts.co.uk

  • TS1846 I have edited a movie in Final Cut Pro and the video has been smoot all the time. Now, when the one hour long movie is ready the video seem to paus every 5 sec (only for half a second). It does it all the way through the movies. What is wrong? Sudd

    I have edited a movie in Final Cut Pro and the video has been smooth all the time.
    Now, when the one hour long movie is ready the video seem to paus every 5 sec (only for half a second). It does it all the way through the movies.
    What is wrong? All the sudden.

    We need info, info, info!
    What version of FCP X?
    Did you render? what are the project specs? do you use many compound clips? how much ram, hard drive space, how is the hard drive connected?
    It looks like your mac can't keep up. Maybe the bottleneck is the hard drive, or something else.
    Try exporting a master file and see if the video is ok.
    Also, keep Activity Monitor open and see how much memory pressure you've got.

  • Hi! I brought an iPhone 4 off my friend at work. The day I brought it, it was working fine but now I can't seem to send any messages or make phone calls. The network is showing up fine but each time I try to make a call it says "call failed" help any1?

    Hi! I brought an iPhone 4 off my friend at work. The day I brought it, it was working fine but now I can't seem to send any messages or make phone calls. The network is showing up fine but each time I try to make a call it says "call failed" I can't seem to send any messages either? I can use the Internet fine and everything else on the phone. Can anyone help?

    Hi chelsinator,
    You can reset the phone and it won't cause any problems or cause you to lose any data - Hold down the Home and Power buttons at the same time and continue to hold them down until the Silver Apple appears.
    The other thing you should do is to reset your network settings: Settings>General>Reset>Reset Network Settings. You will have to set up your Wifi again, but that oftentimes clears things up.
    Cheers,
    GB

  • How would I increment by one each time a sensor's indicator reaches a specific value range?

    Hello -
    In my Labview vi, I need to count the number of times a range of sensor values are reached. I am using the +1 incriment element but becuase the vi's loop is sampled so frequently, it continues to incriment because the loop starts over - and also because the sensor hasn't had a chance to change state yet. I need to just count when something is fully compressed and after the it is expanded, and again compressed - add one.
    Thanks!
    Attachments:
    Mole.vi ‏1263 KB

    Hello,
    Setu's answer was great, and I wanted to provide you with a simple VI showing an example of a state machine. This VI simply uses a boolean switch to change between the expansion and compression states (you would replace this with your code that indicates which state the process is in), and it adds one to the shift register value for each time that the compression occurs. (I added a half-second wait so that the effects can be seen slowly).
    I hope this helps! Have a great day.
    Liz Fausak
    Applications Engineer
    National Instruments
    Attachments:
    compressExpand.vi ‏28 KB
    compressExpand.vi ‏19 KB
    compressExpand.vi ‏16 KB

  • While downloading the free trial for Final Cut Pro X my internet has dropped out many times. It does however seem to continue ok each time it reconnects. Will this affect the software when it finishes? Is this a problem? Any advice please?

    While downloading the free trial for Final Cut Pro X my internet has dropped out many times. It does however seem to continue ok each time it reconnects. Will this affect the software when it finishes? Is this a problem? Any advice please?

    This has happened to me with a few downloads without any upsets.
    You should be OK.
    As I recall the download is around 1.2 gig so it takes a bit of time and effort to get it to your system.
    Al

  • Weird scripting appears each time I open my macbook and freezes everything

    Each time I open my macbook white scripting highlighted in black fills my screen and freezes my whole computer. Each time I have to hold the power button to turn it off. The script starts off with this "panic(cpu 1 caller 0x1109d30): AppleIntelGMAX3100FB GPU parser error. EIR 0x1 ESR 0x1 Instruction Error IPEIR 0 IPEHR 0xafd6e6f7 BBADDR 0 INSTDONE 0xffe5fafd INSTPS 0xb8c32 INSTPM 0x10"
    I have a 2007 black macbook... I need to make it last a little longer. Please help!

    You should never install software or a Firefox extension when a website asks you to do this as this is likely an effort to install malware.
    You can check the target line in the Firefox desktop shortcut (right-click: Properties) to make sure that nothing is appended after the path to the Firefox program.
    Your System Details List shows the Default Tab 2.3.1 and the SafeSearch 2.1 extensions.
    Do a malware check with some malware scanning programs on the Windows computer.<br>
    Please scan with all programs because each program detects different malware.<br>
    All these programs have free versions.
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *Malwarebytes' Anti-Malware:<br>http://www.malwarebytes.org/mbam.php
    *AdwCleaner:<br>http://www.bleepingcomputer.com/download/adwcleaner/<br>http://www.softpedia.com/get/Antivirus/Removal-Tools/AdwCleaner.shtml
    *SuperAntispyware:<br>http://www.superantispyware.com/
    *Microsoft Safety Scanner:<br>http://www.microsoft.com/security/scanner/en-us/default.aspx
    *Windows Defender: Home Page:<br>http://www.microsoft.com/windows/products/winfamily/defender/default.mspx
    *Spybot Search & Destroy:<br>http://www.safer-networking.org/en/index.html
    *Kasperky Free Security Scan:<br>http://www.kaspersky.com/security-scan
    You can also do a check for a rootkit infection with TDSSKiller.
    *Anti-rootkit utility TDSSKiller:<br>http://support.kaspersky.com/5350?el=88446
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Force used cached/local rather than download "script" each time

    in my jsp , i have this
    <script language="javascript" src="something.js"></script>
    so each time the jsp page is loaded, the browser will gurantee go to the server and download something.js . is there anyway to force something.js to remain in user browser cache as long as possible > 30 days or so... so that the next time user visit the website, this something.js can be skipped and speed up page load time?

    I doubt it. Once the user closes his browser, I image the cache is wiped out. Also, it is not likely to keep his browser open for 30 days straight. I don't think this is a good area to look into to speed up your application. Even if you could cache the *.js, I doubt it will speed things up much. In performance tuning, you normally identify the worst bottleneck, fix it, then move on to the next one. Bottlenecks often involve fetching too much data from the database at once (example: fetching all the records from a database table rather than a subset). Also, sending too much information to the display, so much that the user can't possibly use at one viewing. In code, its often creating too many objects.

  • HT201272 I recently upgraded from an Iphone 4S to 5. I am having trouble with magicjack; each time i install it it gives me an error message "The installation associated with this device is invalid". Cannot seem to access account info or make calls.

    I recently upgraded from an Iphone 4S to 5. I am having trouble with magicjack; each time i install it it gives me an error message "The installation associated with this device is invalid". Cannot seem to access account info or make calls.

    I have exactly the same trouble.
    If you wet the answer, please let me know!!

Maybe you are looking for

  • How do I retrieve a deleted PDF file from Adobe Reader on iPad?

    I inadvertently deleted a very important PDF file from the Adobe Reader on iPad. Does anyone know what I can do to retrieve it? A reply would be highly appreciated!

  • Including gauges, bars, pie-diagram etc in Web Dynpro program

    Hi Experts, I am developing one Web Dynpro program. In this program, we have to include fancy features like progress bars, pie-diagram, gauges etc. These items should be related to some R/3 table. For example, if total hours allocated for some work i

  • Upload all my photos to N97

    I'm not having any luck copying all my old N80, N95 photos to my N97 and having the show up on the phone. They were all saved on my PC and MAC, now that it has a bunch of memory I want to keep them on the phone and not delete them. How can I copy my

  • From G3 or G4 to duo core

    can anyone tell me if I will be able to use software from my G3 or G4 on one of thenew macbook duo core machines?? Am thinking of up grading as my ibook is very old and well worn but don't want to have to buy a ton of new software.

  • How do I get my iPad to pair with a device?

    My ipad will not pair with a device. What do I need to do?