Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    syntax errors...javascript for adobe form

    I'm receiving the following errors:

    line 6 Expected an element name[xml]
    line 17 the input ended before all started tags were ended. last tag started was 'script'[xml]


    Code:
    <script type="text/javascript">
    
    var camp = xfa.resolveNodes("camp[*]");
    var total = 0;
    
    for (var i=0; i <= camp.length-1; i++) {
    	if (camp.item(i).isNull) {
    		total = total;
    	}
    	else {
    		total = total + 30;
    	}
    }
    
    this.rawValue = total;
    
    </script>

    I've got next to zero experience with javascript so not even sure what I should be looking to fix...any help is appreciated, if I need to answer something I missed, just let me know.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    Quote Originally Posted by hazydaze View Post
    I've got next to zero experience with javascript so not even sure what I should be looking to fix
    To be honest: Some good beginner's tutorials or books. Your code is way off ... I don't even know where to start ...

    Maybe some hints:
    - Arrays are indexed using [x] and not (x)
    - What is xfa? Where is it defined?
    - Usually there is no such thing as .isNull (except if you defined it somewhere). To test for a null value you can easily use one of those constructs
    Code:
    if(!myvalue) {
       ...
    }
    
    if(myvalue === null) {
       ...
    }
    - There's no need for the keyword "this" in your context. It will just refer to the global window object and can be omitted. But it's not an error to have it either

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,590
    Thanks
    0
    Thanked 644 Times in 634 Posts
    Quote Originally Posted by devnull69 View Post
    To be honest: Some good beginner's tutorials or books. Your code is way off ... I don't even know where to start ...

    Maybe some hints:
    - Arrays are indexed using [x] and not (x)
    but the correct way to reference the item method is using item(x) - since it isn't an array.

    Quote Originally Posted by devnull69 View Post
    - What is xfa? Where is it defined?
    I'd guess that is defined by Adobe (the same way browsers define the window object) since its naming matches the sort of thing Adobe uses in relation to its form handling.

    Quote Originally Posted by devnull69 View Post
    - Usually there is no such thing as .isNull (except if you defined it somewhere)
    again that is probably defined by Adobe.

    Quote Originally Posted by devnull69 View Post
    - There's no need for the keyword "this" in your context. It will just refer to the global window object and can be omitted.
    There is no global window object when running JavaScript in Adobe - the window object only exists when you run JavaScript in a browser.

    I can't spot the error in the code as originally posted as I am not familiar enough with the way JavaScript runs in that environment but whatever the error is will be something very minor. The code is certainly not "way off" as JavaScript running in Adobe is not the same as JavaScript running in a browser.

    The JavaScript manual for Adobe can be found at http://partners.adobe.com/public/dev...croJSGuide.pdf - perhaps that will help you figure out what the error is.
    Last edited by felgall; 03-09-2012 at 01:34 AM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    oooh sorry, that fact escaped me ... after reading the post I forgot about the Adobe aspect because the post doesn't mention Adobe any more :-(

  • #5
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for trying to help out - haven't found the solution yet - but will keep searching!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •