Solved

Multivalues fields - Parsing values

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

  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…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now