hello
i want to extract the value of all the form fields so i have written this code. if there is a different function/better way to do it please let me know
BSTR RESULT;
BSTR Mem1 = SysAllocString(L"var count = 0; count = this.numFields;");
m_spView->RunJavaScript(Mem1, &RESULT, 0, 0);
SysFreeString(Mem1);
int icount = _wtoi(RESULT); i NOW HAS THE NUMBER OF FIELDS IN THE FORM
for (int j=1; j<icount; j++) {
CString JavaString;
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.value;", j); THIS DOES NOT WORK
// JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.name;", j); THIS WORKS AND RETURN FORM NAME
// JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.name,f.value;", j); WOULD THIS RETURN BOTH??? NAME AND VALUE
BSTR Mem2 = SysAllocString(JavaString);
m_spView->RunJavaScript(Mem2, &RESULT, 0, 0);
SysFreeString(Mem2);
}
all is fine - until i TRY to return the value of the form field which it is not doing
my preference is to return the name of the form field and its value
thank you in advance
joe italiano
getting value of form field and its name
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 89
- Joined: Wed Dec 29, 2010 8:50 am
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: getting value of form field and its name
Hi joe,
As I have test it, this line
works fine. Please make sure that you are using latest build of Viewer. Also you may test JS in standalone Viewer just to check how it works.
Using this code you will get only field value.
HTH.
As I have test it, this line
Code: Select all
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.name;", j);
Code: Select all
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.name,f.value;", j); WOULD THIS RETURN BOTH??? NAME AND VALUE
HTH.
-
- User
- Posts: 89
- Joined: Wed Dec 29, 2010 8:50 am
Re: getting value of form field and its name
hi corwin
i agree that
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.name;", j);
works but the following code does not work and it is the form field value i need
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.value;", j); THIS DOES NOT WORK
joe
i agree that
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.name;", j);
works but the following code does not work and it is the form field value i need
JavaString.Format(L"var fname = this.getNthFieldName(%d);var f = this.getField(fname);f.value;", j); THIS DOES NOT WORK
joe
-
- Site Admin
- Posts: 19885
- Joined: Mon Jan 12, 2009 8:07 am
Re: getting value of form field and its name
Hello Joe,
I have asked Corwin to take another look here, but in the mean time please ensure that you are using build 193, as in the end user Viewer at least, using the JS console I was able to obtain both the form name and value.

The file I tried with is this one.
Best,
Stefan
I have asked Corwin to take another look here, but in the mean time please ensure that you are using build 193, as in the end user Viewer at least, using the JS console I was able to obtain both the form name and value.

The file I tried with is this one.
Best,
Stefan
-
- User
- Posts: 89
- Joined: Wed Dec 29, 2010 8:50 am
Re: getting value of form field and its name
hi stefan
from what i can see i am
i have attached a zip file with the app source
look at the close function or search for f.value dlgdocument.cpp
cheers
joe
from what i can see i am
i have attached a zip file with the app source
look at the close function or search for f.value dlgdocument.cpp
cheers
joe
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: getting value of form field and its name
Hello Joe,
And again - all works fine for me (name and value gets fine). Can you please send us sample file where you get such problems?
Also note that annots array is zero based, so if you want to get all annots, you should change your "for" statement:
And again - all works fine for me (name and value gets fine). Can you please send us sample file where you get such problems?
Also note that annots array is zero based, so if you want to get all annots, you should change your "for" statement:
Code: Select all
for (int j=0; j<icount; j++)
-
- User
- Posts: 89
- Joined: Wed Dec 29, 2010 8:50 am
Re: getting value of form field and its name
hi corwin
did you test with the source code from the zip file i sent you
joe
did you test with the source code from the zip file i sent you
joe
-
- User
- Posts: 89
- Joined: Wed Dec 29, 2010 8:50 am
Re: getting value of form field and its name
all fixed it was the pdf file that was corrupted works ok with the others
thank you all
thank you all
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 19885
- Joined: Mon Jan 12, 2009 8:07 am