?
Solved

retrieving field values from one form to another

Posted on 2004-08-20
10
Medium Priority
?
204 Views
Last Modified: 2013-12-18
Hi all,

For my web application, I have form1 and form2. I have a bunch of fields in both the forms. Is it possible for me to display the field values of form1 in form2
For example: if i have a field "company1" in form1 and the user enters its vaLue in the browser and it gets saved.
Now, is there any way i can automatically display the value of field "company1" in the field "company2"(of the form2) ,when the form2 is opened in the browser?

Any responces greatly apprecited.

thanks
J  
0
Comment
Question by:jaggernat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
10 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 11861502
There is a pure JavaScript version for that problem using Cookies.
And a second variant using @Formulas and ProfileDocuments.

I would recommand the Cookie method. Are you interested?

0
 
LVL 10

Author Comment

by:jaggernat
ID: 11861744
yes , please ..i would appreciate it..

Thanks,
Jay
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 11862414
Ok, here a tested version:

Put this in Form1 JSHeader:

var fieldMap = ["Company1:company", "EmailAddress1:email","City1:city"];

function putFields(theForm){
   theForm = document.forms[0];
   cVal = document.cookie.split("sF=");
   if(cVal.length==2){
     cVal = unescape((cVal[1]+";").split(";")[0]);
   } else {
     cVal = "";
   }
   for(i=0;i<fieldMap.length;i++){
      fVal = theForm[fieldMap[i].split(":")[0]].value;
      cNam = fieldMap[i].split(":")[1];
      cVal = cVal.replace(new RegExp(cNam+"\\=[\\w\\% \\@]*\\:","g"),"");
      cVal += cNam+"="+escape(fVal)+":";
   }
   document.cookie="sF="+cVal+";path=/;";
}

Put this in Form1 onSubmit event:

 putFields(this)


Put this in Form2 JSHeader:

var fieldMap = ["Company2:company", "EmailAddress2:email","City2:city"];

function getFields(){
   theForm = document.forms[0];
   cVal = document.cookie.split("sF=");
   if(cVal.length==2){
     cVal = unescape((cVal[1]+";").split(";")[0]);
     for(i=0;i<fieldMap.length;i++){
        fNam = fieldMap[i].split(":")[0];
        cNam = fieldMap[i].split(":")[1];
         if(cPart=cVal.match(new RegExp("\\b"+cNam+"\\=([\\w\\% \\@]*)\\:"))){
            if(cPart.length==2) theForm[fNam].value = unescape(cPart[1]);
         }
      }
   }
}


Put this in Form2 onLoad event:

getFields()


Short description:
In Form1 does the Array  fieldMap contain pairs of Form1 field names (be aware of exact uppercase and lowercase characters) folowed by a colon and the name for that field in the cookie.
The name in the cookie is the field reference for any other form to get that field value not by the Field name like used in Form1 but by a normalized cookie field name.
So is the Array in Form2 also pairs with the Field names as used on Form2 and the coresponding cookie name.
You have not to use all Form1 fields in Form2. Only used field names will overwrite the Form2 fields and only if the cookie contains a value for that field.

Tell me how it works for you.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 63

Expert Comment

by:Zvonko
ID: 11862441
Sorry, take better this function versions:


function putFields(theForm){
   theForm = document.forms[0];
   cVal = document.cookie.split("sF=");
   if(cVal.length==2){
     cVal = unescape((cVal[1]+";").split(";")[0]);
   } else {
     cVal = "";
   }
   for(i=0;i<fieldMap.length;i++){
      fVal = theForm[fieldMap[i].split(":")[0]].value;
      cNam = fieldMap[i].split(":")[1];
      cVal = cVal.replace(new RegExp(cNam+"\\=[\\w\\% \\@]*\\|","g"),"");
      cVal += cNam+"="+escape(fVal)+"|";
   }
   document.cookie="sF="+escape(cVal)+";path=/;";
}


And for Form2 this:
function getFields(){
   theForm = document.forms[0];
   cVal = document.cookie.split("sF=");
   if(cVal.length==2){
     cVal = unescape((cVal[1]+";").split(";")[0]);
     for(i=0;i<fieldMap.length;i++){
        fNam = fieldMap[i].split(":")[0];
        cNam = fieldMap[i].split(":")[1];
         if(cPart=cVal.match(new RegExp("\\b"+cNam+"\\=([\\w\\% \\@]*)\\|"))){
            if(cPart.length==2) theForm[fNam].value = unescape(cPart[1]);
         }
      }
   }
}


0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11862446
Sorry, one more improvement:

function putFields(theForm){
   theForm = document.forms[0];
   cVal = document.cookie.split("sF=");
   if(cVal.length==2){
     cVal = unescape((cVal[1]+";").split(";")[0]);
   } else {
     cVal = "";
   }
   for(i=0;i<fieldMap.length;i++){
      fVal = theForm[fieldMap[i].split(":")[0]].value;
      cNam = fieldMap[i].split(":")[1];
      cVal = cVal.replace(new RegExp(cNam+"\\=[^\\|]*\\|","g"),"");
      cVal += cNam+"="+escape(fVal)+"|";
   }
   document.cookie="sF="+escape(cVal)+";path=/;";
}


And for Form2:
function getFields(){
   theForm = document.forms[0];
   cVal = document.cookie.split("sF=");
   if(cVal.length==2){
     cVal = unescape((cVal[1]+";").split(";")[0]);
     for(i=0;i<fieldMap.length;i++){
        fNam = fieldMap[i].split(":")[0];
        cNam = fieldMap[i].split(":")[1];
         if(cPart=cVal.match(new RegExp("\\b"+cNam+"\\=([^\\|]*)\\|"))){
            if(cPart.length==2) theForm[fNam].value = unescape(cPart[1]);
         }
      }
   }
}



0
 
LVL 10

Author Comment

by:jaggernat
ID: 11862682
hi,

sorry, the problem is  a one level more complex. i want to retrieve a field value from a stored document to a form in a browser.
For a clear description, here it is:
The value of "company" field (IIT) in this link    :   http://216.47.158.148/AMSStaff.nsf/ad2205b8b2c4ae4e86256e9b000e0553/142f6f40f11c2aa486256ef500605901?OpenDocument&Highlight=0,iit*     

should be displyed in the jobtitle field  in this form link:    


 http://216.47.158.148/AMSStaff.nsf/ApplyJobs?OpenForm

do i have to make any modifications.


thanks,
J
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11862858
Please assign for my work here the grade A and open a new question with more details.
My upper solution did exactly what you asked for in the original question.

I can help you with the new requirment and with the $$LoginUserForm
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11865523
Ok, thanks for points and grading.

You can open a new question for the changed requirment but I can give you the answer also here: the changed requirment is far too simple!
To get a value from one document to next Form you need NO scripting. It is a built in feature of Notes to inherit values from a document to a new documetn.
Check in the new Form a form property with the label: "FormulaInheritValuesFromSelectedDocument"
That property is the first checkbox in the propelar hat tab in Form properties.
So the only thing you have to do is to click that checkbox in your Form ApplyJobs in the AMMSStaff.nsf
After that you have to put in your Field "Subject" in the ApplyJobs Form this formula for the DefaultValue: company
That's all.




0
 
LVL 10

Author Comment

by:jaggernat
ID: 11866074
i did check the "FormulaInheritValuesFromSelectedDocument" form property in apply jobs and gave the default value of field"subject"  as company.

But it does not display the company value in the apply jobs form..
i am confused..
How does the apply jobs form(which is dynamic) retrieve value from the static document.


thanks,
J

 
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11866180
Please open a new question.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question