-
1. Re: how to take a field value in an array?
try67 Aug 30, 2011 4:15 AM (in response to Arshad Qazi)Be more specific. What is it you're trying to achieve, exactly?
You can push a field value to an array like you do any other value.
-
2. Re: how to take a field value in an array?
Arshad Qazi Aug 30, 2011 4:22 AM (in response to try67)theres a condition wherein we need to take the field value which is a numeric value and we have to take it in a array to take out odd fields...... and then again from array transfer to a variable for further use.... my question is how to take the number in a field in an array and how to extract each array element to get a string of number??
-
3. Re: how to take a field value in an array?
try67 Aug 30, 2011 4:25 AM (in response to Arshad Qazi)To add a field to an array:
var arr = new Array();
var v = getField("FieldName").value;
arr.push(v);
To get all the elements of an array (in this case, they are printed to the
console):
for (var i=0; i<arr.length; i++) {
console.println(arr[i]);
}
-
4. Re: how to take a field value in an array?
Arshad Qazi Aug 30, 2011 4:27 AM (in response to Arshad Qazi)suppose i have taken field value in a temp variable...........
and temp2 is an array in which i need to push the field value (i.e temp)
var temp = this.getField("accountNumber").valueAsString;
temp2 = new Array(24);
for (i=0; i<25 ; i++)
{
temp2[i] = temp[i];
}will my numbers get inserted into temp2 array?? and now how to extract the each digit to get a number again?
-
5. Re: how to take a field value in an array?
try67 Aug 30, 2011 4:31 AM (in response to Arshad Qazi)Yes, each character in the value of "accountNumber" will be saved into a
different item in the array, but you might want to make sure that there are
actually 24 characters, or an exception will be thrown.
To convert a string to a number, use the Number() method, like so:
var a = "12";
var b = Number(a); // b is now the number 12
-
6. Re: how to take a field value in an array?
Arshad Qazi Aug 30, 2011 4:47 AM (in response to try67)thank u very much...... but i have one more doubt
for the same example -
temp2 = new Array(24);
temp2.push(temp);
for(var i=0; i<temp2.length; i+2)
{
var chkDigit = temp2[i];
}here i need to take odd numbers in a variable but m quite sure, every time loop executes it will overwrite the previous one, so wot additional code we got to write to have chkDigit variable hold all the digit
-
7. Re: how to take a field value in an array?
try67 Aug 30, 2011 4:50 AM (in response to Arshad Qazi)Change it into an array and push the values into it.
-
8. Re: how to take a field value in an array?
Arshad Qazi Aug 30, 2011 5:07 AM (in response to try67)yaa... i know, but actually we need to multiply that number with some digit.
take it this is way, if i push it into another array, we have an array of digits but what i need is a all digit to be together to be multiplied to a number
for example -
if i push the numbers into new array say arr[];
so i will have something like this. arr[1,2,3,4,5,6.......]
but i need the new varaible should have value as 12345........ all concatenated.
if i perform operation on array each digit will be multiplied individually.
hope u got what m trying to sayy....
Thanks for the prompt response..........
-
9. Re: how to take a field value in an array?
try67 Aug 30, 2011 5:12 AM (in response to Arshad Qazi)I suggest you read up a bit on JS. These are standard issues that are not
related to Acrobat, as such.
I would recommend this website: http://www.w3schools.com/js/default.asp
Specifically, to answer your question, you can use the join() method.
See here: http://www.w3schools.com/jsref/jsref_join.asp
You can then turn that string into a number using the Number method I
described earlier.
-
10. Re: how to take a field value in an array?
Arshad Qazi Aug 30, 2011 5:16 AM (in response to try67)thank u.............


