Solved

Multivalues fields - Parsing values

Posted on 2003-10-22
5
401 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
[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
  • 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

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

622 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