...

View Full Version : syntax errors...javascript for adobe form



hazydaze
03-08-2012, 06:21 PM
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]





<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.

devnull69
03-08-2012, 09:06 PM
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


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

felgall
03-09-2012, 01:29 AM
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.


- 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.


- Usually there is no such thing as .isNull (except if you defined it somewhere)

again that is probably defined by Adobe.


- 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/developer/en/acrobat/sdk/AcroJSGuide.pdf - perhaps that will help you figure out what the error is.

devnull69
03-09-2012, 07:24 AM
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 :-(

hazydaze
03-12-2012, 10:25 PM
Thanks for trying to help out - haven't found the solution yet - but will keep searching!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum