Solved

Multivalues fields - Parsing values

Posted on 2003-10-22
5
400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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