Solved

Multivalues fields - Parsing values

Posted on 2003-10-22
5
399 Views
Last Modified: 2013-12-18
I have a form which holds SLA parameters.  It has a number of hidden multivalue textfields which take the following name format.

CA01_Rec
CA02_Rec
CA03_Rec
DR01_Rec
etc...

Each field has a corresponding button when the user clicks on the button it opens up a window parsing the fieldname in the URL.  

The new window contains a checkbox field of users, when the user selects the users and saves the form the following code fills the value on the parent form.

function updateParent()
{
fieldname = frm.FieldName.value;  
intLength = document.forms[0].elements['Rec'].options.length;
      
if(intLength>-1)
{
     for (i=0; i<intLength;i++)
     {
      newValue= document.forms[0].strList.options[i].text;                 
      if (listval =="") { listval = newValue }
      else                   { listval = listval + ";" + newValue}
     }
}
opener.document._frmSLA[fieldname].value =  listval;
window.close()
}

What I want to do it when the user clicks on the button to open up the window the values in the hidden field are parsed so that the values that the user has previously saved are checked.  Any ideas how I do this?
0
Comment
Question by:fayeb
  • 2
  • 2
5 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 50 total points
ID: 9600768
Paste this code in onload event of the dialog form.

prevVal = window.opener.document.forms[0].MValues.value;    // Parent doc val
var thisform = document.forms[0];
for(i=0; i<thisform.MValues.length; i++) {
if(thisform.MValues[i].value == prevVal) {
      thisform.MValues[i].checked = true ;
}
}



Substitute MValues with your field name appropriately

~Hemanth
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9601707
Hi fayeb,

I'm a little cnfused as to what yuo mean.  I was first thinking along the lines of what Hemanth did, but then I realized you might have meant THE OPPOSITE. Hemanth's code runs in the secondary (popup) window, gets the parent form's field value.  Then, for each current possible checkbox, it checks off the value if it matches.

This does NOT describe how to send values back from th epopup to the main window.  And it does not describe how to retrieve a multiple value field from the main doc.

Multiple value text fields in Notes are sent as a single field, with a separator breaking up the multiple values.  Usually, the separator is a comma followed by a space, but this is configurable within a small set of choices).  So you need to use value.split(",") and then trim off the leading space from each value except for the first.

Multiple value fields that use keywords will make use of the browser equivalent (checkbox, listbox).

Best regards,
qwaletee
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 200 total points
ID: 9601782
So, modifying Hemanth's code to account for multiple values on the source...

function LTrim(str){if(str==null){return null;}for(var i=0;str.charAt(i)==" ";i++);return str.substring(i,str.length);}
prevVal = LTrim(window.opener.document.forms[0].MValues.value.split(","));    // Parent doc val
var thisform = document.forms[0];
for(i=0; i<thisform.MValues.length; i++) {
 for(j=0; j<prevVal.length;j++){
  if(thisform.MValues[i].value == prevVal[j]) {
       thisform.MValues[i].checked = true ;
  }
 }
}
0
 

Author Comment

by:fayeb
ID: 9605090
you seem to be passing a variable called str can you please tell me what that is relating to.
0
 

Author Comment

by:fayeb
ID: 9605294
Thanks guys for both your help.  I managed to work it outand get the code working.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to retrive archive emails from nsf file if it is overwritten 12 73
Lotus notes email code 2 210
Adding a named anchor in a Lotus Notes Form 6 99
lotus notes, exchange 7 111
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 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