Please help with a custom javascript

Hello,
I am a military instructor, and I am trying to create a grade report card with Acrobat X Pro.  So far I have made good progress with the help of the forum community (just searching through the pages and pages of posts), but I am stuck on this issue.
Like I stated,  I am creating a report card (of sorts) where our other instructor staff can input student test grades into the fields as they [students] progress through training.  The form is showing the particular test with an input field for the grade.  Lastly, the student's overal GPA is displayed in percent format.
My conundrum: I am trying to code a field that all a user [instructor] will have to input is a numerical value with or without a decmil, and the field will display it as a percentage. 
If I use acrobats default percentage, the number entered into the field will be multiplied by 100 (i.e. I enter 90 and acrobat displays 9000% in the field).
I would just like to be able to type in 90, and 90% be displayed; or type in 88.5, and 88.5% be displayed.
With the scripts I have entered, no decmils can be displayed, and the overal score is multiplying the average by 100, thus if I entered the number 90 in the first exam, the average calculates to 9000%.
I am assuming the custom format script and custom keystroke script made the average calculation script not work correctly.
Thanks in advance.  Ryan
I have entered the following javascripts:
1.  Document Level Script
// Document-level function
function DigOnlyKS() {
    // Get all that is currently in the field
    var val = AFMergeChange(event);
    // Reject entry if anything but digits
    event.rc = AFExactMatch(/\d*/, val);
2.  Custom Format Script
// Custom Format script for text field
if (event.value) event.value += "%";
3.  Custom Keystroke Script
// Custom Keystroke script
DigOnlyKS();
4.  Custom Calculation Script for an Overal Grade Average
event.value = myAverageFunction(["pk1","pk2","pk3","pk4","pk5","pk6","pk7","pk8","pk9","pk10","pk11","p k12","pk13","pk14","pk15","pk16","pk17","pk18","pk19","pk20","pk21","pk22","pk23","pk24"," pk25"]);
function myAverageFunction(aNames) {
    // n = number of fields that have a numerical value
    // sum = some of values for the named fields
    var n = 0;
    var sum = 0;
    var v;
    // loop through array of name strings
    for (i = 0; i < aNames.length; i++) {
      v = this.getField(aNames[i]).valueAsString;
      // check for not a null string and not a space  and not is Not a Number
      if (v != "" & v != " " & isNaN(v) == false) {
         n++; // increment count
         sum += Number(v); // add to sum
    return (n != 0) ? (sum / n): "";

Try,
I'm sorry for being so ignorant with javascript.
I placed that code in the custom keystroke like you suggested, but it did not work.    Is there a specific way I need to input that code in the custom keystroke area?
I then tried to put it in the document level code and replaced (/\d*/, val) with your code... that really screwed thing up.
So now I am stuck where I was before.
I will try and show you what I am trying to accomplish:
Right now, this is what is happening
Exam 1
Exam 2
Exam 3
Final Average
95.5%
95.3%
94.3%
95.033333%
What I would like to do is to limit each field to 2 decmil places.
Each "exam field" has the following:
The "final average" field has the following:
and this is in the custom calculations area of the "final average" field:
Finally, I have this in the Documet JavaScripts area:
I have a feeling this is an easy fix, but I just cannot figure it out.
Thanks,
Ryan

Similar Messages

  • Please help with some basic javascript syntax

    Can anyone please help me with a "remove from favourites"
    facility i'm working on.
    I query to get all the favouites, then i output those
    favourites down the page
    each favourite has a "remove from favourites" link - i want
    to make it so when a user clicks this link they get a javascript
    confirm box pop up saying "are you sure you want to remove
    #favourites name# from your favourites?"
    so i have..
    function remove(profile,name) {
    if (confirm("Are you sure you want to remove #name# from
    your favourites?")) {
    window.location =
    "remove_from_favourites.cfm?deleteFavID=#profile#&removedName=#name#"
    and
    <div
    onClick="remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)"
    >Remove from favourites</div>
    but it doesn't work - i think there are 2 problems..
    problem 1 - i have used the CF # in the remove function as i
    don't know what one does in javascript to "output" a variable (see
    where it says "Are you sure you want to remove #name# from your
    favourites") what should i use in place of the "#"?
    problem 2 - i have tried to pass to variables to the function
    >>
    onClick="remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" and i
    have separated them but a commer "," but i suspect that is
    incorrect syntax
    if anyone could please help me i'd be very grateful as, to be
    honest, i love coldfusion - but javascript just hurts my head! :(
    thanks very much indeed.
    PS the way i've wrapped my "remove from favourites" text in a
    div rather than making it an actual "a href" link - is that right
    or is there a better way (ideally i'd like the text to look like
    all my other links (ie they underline on mouse over)

    You can simply add CSS commands to define your div to look
    like your links.
    div#FavLink
    color: blue;
    text-decoration: underline;
    cursor: pointer;
    <div id="FavLink"
    onClick="remove(#rs_favs.favouriteeID#,'#rs_favs.firstName#')"
    Remove
    from favourites</div>
    That should get you started.
    happysailingdude wrote:
    > thanks CFDEBUG that sorted it - thanks very much
    >
    > just one last thing - more of a CSS issue i think but
    maybe not.
    >
    > so now I have <div
    >
    onClick="remove(#rs_favs.favouriteeID#,'#rs_favs.firstName#')"
    >Remove from
    > favourites</div>
    >
    > which of course isnt a link so it just looks like my
    standard text (as if i'd
    > done <p>Remove from favourites</p>
    >
    > how do i make the "Remove from favourites" text look
    like a link as if i'd
    > done <a href="remove_from_favourites.cfm?....."
    >Remove from favourites</a>
    >
    > i think ive seen links that when you hover over them it
    says "javascript:void"
    > or something at the bottom of the browser - is this the
    answer and if so what
    > is the correct syntax please? or do i need to do
    something with my CSS file?
    >
    > thanks very much indeed for any further help anyone can
    give me to get this
    > page finshed off - thank you
    >

  • HT5824 I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. Please help with turning my iMessage completely off..

    I switched over from an iPhone to a Samsung Galaxy S3 & I haven't been able to receive any text messages from iPhones. I have no problem sending the text messages but I'm not receivng any from iPhones at all. It has been about a week now that I'm having this problem. I've already tried fixing it myself and I also went into the sprint store, they tried everything as well. My last option was to contact Apple directly. Please help with turning my iMessage completely off so that I can receive my texts.

    If you registered your iPhone with Apple using a support profile, try going to https://supportprofile.apple.com/MySupportProfile.do and unregistering it.  Also, try changing the password associated with the Apple ID that you were using for iMessage.

  • How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore. Please help with proper steps, if any.

    How can I sync my iPhone on a different computer without erasing my applications? My iPhone was earlier synced with a PC which I don't use anymore.
    On the new computer, I am getting a message that my all purchases would be deleted if I sync it with new iTunes library.
    Please help with proper steps, if any.

    Also see... these 2 Links...
    Recovering your iTunes library from your iPod or iOS device
    https://discussions.apple.com/docs/DOC-3991
    Syncing to a New Computer...
    https://discussions.apple.com/docs/DOC-3141

  • Please help with "You can't open the application NovamediaDiskSupressor because PowerPC applications are no longer supported." I have seen other responses on this but am not a techie and would not know how to start with that solution.

    Please help with the message I am receving on startup ""You can't open the application NovamediaDiskSupressor because PowerPC applications are no longer supported."
    I have read some of the replies in the Apple Support Communities, but as I am no techie, I would have no idea how I would implement that solution.
    Please help with what I need to type, how, where, etc.
    Many thanks
    AppleSueIn HunterCreek

    I am afraid there is no solution.
    PowerPC refers to the processing chip used by Apple before they transferred to Intel chips. They are very different, and applications written only for PPC Macs cannot work on a Mac running Lion.
    You could contact the developers to see if they have an updated version in the pipeline.

  • Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be ab

    Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.

    Adobe - Lightroom : For Macintosh
    Hal

  • [ETL]Could you please help with a problem accessing UML stereotype attributes ?

    Hi all,
    Could you please help with a problem accessing UML stereotype attributes and their values ?
    Here is the description :
    -I created a UML model with Papyrus tool and I applied MARTE profile to this UML model.
    -Then, I applied <<PaStep>> stereotype to an AcceptEventAction ( which is one of the element that I created in this model ), and set the extOpDemand property of the stereotype to 2.7 with Papyrus.
    -Now In the ETL file, I can find the stereotype property of extOpDemand as follows :
    s.attribute.selectOne(a|a.name="extOpDemand") , where s is a variable of type Stereotype.
    -However I can't access the value 2.7 of the extOpDemand attribute of the <<PaStep>> Stereotype. How do I do that ?
    Please help
    Thank you

    Hi Dimitris,
    Thank you , a minimal example is provided now.
    Version of the Epsilon that I am using is : ( Epsilon Core 1.2.0.201408251031 org.eclipse.epsilon.core.feature.feature.group Eclipse.org)
    Instructions for reproducing the problem :
    1-Run the uml2etl.etl transformation with the supplied launch configuration.
    2-Open lqn.model.
    There are two folders inside MinimalExample folder, the one which is called MinimalExample has 4 files, model.uml , lqn.model, uml2lqn.etl and MinimalExampleTransformation.launch.
    The other folder which is LQN has four files. (.project),LQN.emf,LQN.ecore and untitled.model which is an example model conforming to the LQN metamodel to see how the model looks like.
    Thank you
    Mana

  • Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs

    Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs

    Upgrade to 11.2.0.3 -- Interoperability Notes Oracle EBS R12 with Oracle Database 11gR2 (11.2.0.3) (Doc ID 1585578.1)
    Upgrade to 11.2.0.4 (latest 11gR2 patchset certified with R12) -- Interoperability Notes EBS 12.0 and 12.1 with Database 11gR2 (Doc ID 1058763.1)
    Thanks,
    Hussein

  • Welcome. At the outset, I'm sorry for my English :) Please help with configuration Photoshop CS6 appearance. How to disable the background of the program so you can see the desktop. (same menus and tools) Chiałbym to be the same effect as CS5.

    Welcome.
    At the outset, I'm sorry for my English
    Please help with configuration Photoshop CS6 appearance.
    How to disable the background of the program so you can see the desktop. (same menus and tools)
    i wantto be the same effect as CS5.

    Please try turning off
    Window > Application Frame

  • HT201210 cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?

    cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?

    If you mean updae server
    Update Server
    Try:
    - Powering off and then back on your router.
    - iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
    - Change the DNS to either Google's or Open DNS servers
    Public DNS — Google Developers
    OpenDNS IP Addresses
    - For one user uninstalling/reinstalling iTunes resolved the problem
    - Try on another computer/network
    - Wait if it is an Apple problem
    Otherwise what server are you talking about

  • HT3209 Purchased DVD in US for Cdn viewing. Digital download will not work in Cda or US? please help with new Digital code that will work

    Purchased DVD in US for Cdn viewing. Digital download will not work in Cda or US? please help with new Digital code that will work

    You will need to contact the movie studio that produced the DVD and ask if they can issue you a new code valid for Canada. Apple cannot help you, and everyone here in these forums is just a fellow user.
    Regards.

  • Please help with slideshow problems!

    Am using Photoshop Elements 8 and trying to make a slideshow. Have tried 4 times now and keep ending up with same problem, cannot reopen project to continue edititing.  Won't show up in orginizer and when I find on harddrive and try to open get message " wmv file cannot be opened".  How can I save a
    slideshow inprogress and be able to reopen and continue to edit and make slideshow?  I want to thank anyone who can help me with this in advance as I
    have gotten so frustrated that I want to just scream.
    Thanks

    Thanks for the help, thought I had done so but maybe not.  Anyway will have another go at it, now may I ask another
    question?  I am trying to add audio to slideshow.  I have some music I purchased thru amazon as mp3 files but I get
    message no codec and when I try to add wmv I get same message.  What type of file do I need and how can I add
    multiple songs to one slideshow.   I have one little wmv file that will go in, but it just replicates itself multiple times until
    it fills slide show. 
    Thanks again, sorry to be a bother, but this thing is driving this old man crazy.
    Date: Sun, 26 Dec 2010 20:34:32 -0700
    From: [email protected]
    To: [email protected]
    Subject: Please help with slideshow problems!
    You need to save the slideshow project in order to be able to go back later and make changes or additions to an existing slideshow . The wmv file is a final output format.
    Now you are most probably using only the Output command: that is what makes the wmv file.
    You should also do the Save Project command. (and I make it a practice to do the Save Project command before I do the Output command).
    If you look at the Elements Organizer 8 Help, there is a topic on "Create a slide show".
    -- Very close to the beginning of that topic is a screen shot of the Sldie Show Editor screen,
    -- The bar below the usual menu bar is labeled with a "B" and called the Shortcuts bar.
    -- The 1st entry on that Shortcuts bar is "Save Project"
    It is the Save Project command that saves the information about which photos, audio, etc you placed in that specific slide show so that you can come back again to do subsequent editing.  Save each Project with a unique name.
    After completing the Save Project command, you shoud see an "icon" in the Organizer for that slide show.
    Note:  you must also keep the photo files and audio files which you have used in this slide show: you can't delete them because the project file does NOT contain a copy of the photos, it only has the identification and folder location of the photo and audio files.
    >

  • Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hello Priyanks,
    I found an article with steps you can take to troubleshoot issues with an iPhone not connecting to your car stereo:
    iOS: Troubleshooting car stereo connections
    http://support.apple.com/kb/TS3581
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • My "fn" button is stuck on only revealing mission control in Lion. With this problem none of my "f" keys will work nor can I hold "fn" and delete to delete text in opposite direction. Can someone please help with this?

    My "fn" button is stuck on only revealing mission control in Lion. With this problem none of my "f" keys will work nor can I hold "fn" and delete to delete text in opposite direction. Can someone please help with this?

    Following the fix here worked for me:
    https://discussions.apple.com/message/15680566#15680566
    except my plist file was in ~/Library instead of /Library.
    -Scott

  • Ipod Nano 6th generation setting issue - hi, when i am listening music and the screen goes to sleep my music stop playing.Please help with settings

    hi, when i am listening music and the screen goes to sleep my music stop playing.Please help with settings

    No problem.   And no worries, several people have made this same mistake!
    Either way enjoy the iPod!
    Brock

Maybe you are looking for

  • MAC PRO REFUSES TO BE CLOCKED BY EXTERNAL WORDCLOCK!

    I used my Apogee Rosetta 200 as AD/DA and Wordclock going direktly into optical input on a G5 ... worked perfectly together for years. pretty much what i loved macs for. alas! those times are gone. with my new built mid 2010 machine and os 10.6.8 run

  • DI UI : fill matrix with a query from user table data

    hello, I create a user table. I want to fill a matrix on a form with some aggregated data of this user table. I do : Public Sub SetMatrixRep()   Dim oRecordSet As SAPbobsCOM.Recordset   Dim oCentre As SAPbouiCOM.EditText   Dim oCompte As SAPbouiCOM.E

  • My Library isnt showing any of my files or playlists!

    In a recent attempt to save some space on my C drive, I moved the iTunes folder out of My Documents and into a seperate drive on my partitioned hard drive. I went into the preferences menu to change the location that iTunes looks for the the playlist

  • Error while initializing activation agent for DBAdapter MasterDetail Demo.

    God day, following precisely the steps in Master Detail -Database Adapter sample. - configured adapter and deployed project and everything looked fine. - when start the Process Manager, always get: ( Error while initializing an activation agent for p

  • Song name in other languages

    I downloaded a song which has a hebrew name and informaton. The song information comes up as weird characters. Is there a way to display the hebrew characters?