Solved

JavaScript to change Dialog list

Posted on 2002-04-11
31
957 Views
Last Modified: 2013-12-18
I have the following JS code in a button

var option1 = new Option(mainform .F1_Desc1.value, mainform.F1_Desc1.value);
mainform.mF1_Desc1.options[varCurr] = option1;

for (i=0;i<mainform.mF1_Desc1.length;i++) { mainform.mF1_Desc1.options[i].selected = true;  }

F1_Desc1 is an editable field
mF1_Desc1 is a Dialog list, allow multiple values.
varCurr is a numeric value (0,1,2)

I want to replace the value in mF1_Desc1 with the new value in F1_Desc1 slotted according to varCurr.

The code works fine, and in the notes client the value for mF1_Desc1 is changed to the new value. However, when I display the document for editing on the web, the Dialog list box is empty (eventually when editing, F1_Desc1 will be = mF1_Desc1(0).

Why isn't the new value showing up on the web?

0
Comment
Question by:GaryZ
  • 11
  • 9
  • 6
  • +1
31 Comments
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
After setting the value are you doing a refresh on the document ?  Try that !
0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Here is the mistake, the changes you made or to the web page and not saving on notes side. Do this trick instead

Create a field Called Temp (Editable and hidden on read and edit), the values should be seperated by comma.
eg: "1,2,3"

Have the option values that you would like to show it in the mF1_Desc1

In mF1_Desc1 , the keyword formula should be @Explode(Temp)

Then the javascript would look like this.

var varCurr = 1;
var option1 = new Option(F1_Desc1.value, F1_Desc1.value);
Temp.value = "";
mF1_Desc1.options[varCurr] = option1;
mF1_Desc1.options[varCurr].selected = true;
for (i=0;i<mF1_Desc1.length;i++) {
     Temp.value = Temp.value + "," + mF1_Desc1.options[i].text;

}

Now saved doc will have modfied options and so the next load would be correct.

~Hemanth

0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Hello Gary,

You have to change the way how you define the values for the DialogList named: mF1_Desc1

Instead of entering some (or none) values line by line for the dialog list do select the value option: UseFormulaForChoices

For the formula enter the name of the DialogList field: mF1_Desc1

If you like to have default options for this DialogList field, then enter them in the Default value for the field, like this:
"oldOpt1":"oldOpt2":"oldOpt3"

That should do the trick.

Regards,
Zvonko

0
 

Author Comment

by:GaryZ
Comment Utility
Real close, I can now see the values when I edit the form.

Using your code (changed varCurr = 1 to varCurr = main.all.CurrentLocation.value - 1;)

I enter  Aaaaa into F1_Desc1 and click button.
mF1_Desc1 is = Aaaaa and Temp is = ,Aaaaa (shouldn't this be (Aaaaa,,)?

Now, when I go to edit the document mF1_Desc1 = Aaaaa and Temp = Aaaaa. I then enter Bbbbb into F1_Desc1 (varCurr is still the same value). The Aaaaa in mF1_Desc1 and Temp is now Bbbbb.

However, when I now go to edit the form the values in mF1_Desc1 and Temp are back to Aaaaa. For some reason they are not getting saved. I use the same button to save a new form as is used to save the edited form.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Aaaaa,, or ,Aaaaa doesn't matter because the explode function pares commas as seperators and null are neglected.

In your case I believe that the form is not saving properly. I did try the same setup here and works. Unless you are doing something different.

One small thing that I forgot to mention is, check the generate html for all fields in the form defaults page. So that the hidden temp field will have a html equivalent generated.

If you want me to take a look at the db, then send me the db with just one form in context and a doc for testing to hemanth@boxfrog.com
0
 

Author Comment

by:GaryZ
Comment Utility
Thanks I emailed a really stripped down database to you.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
I tested your form as per your instructions and found to be ok. I don't find any problem. It is working as designed.

Is there something that I am missing !!!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Ok found it.

It is not the problem with JS, the edit button is constantly loading only one document (which is the first document in the view). You have to change the way you edit document, it's url is always constant, and it necessarily doesn't match the current document
0
 

Author Comment

by:GaryZ
Comment Utility
Not sure I am following you here. My database uses a view to lookup the form based on a UniqueKey that is generated when the form is composed the first time. I changed the database I sent you to generate 1 key and then loaded that form.

My current coding for the Edit button is:

@SetTargetFrame("main");
@URLOpen("http://" + Server_Name + "/" + DataBase + "/Lookup2/" + UniqueKey + "?EditDocument")
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Gary, why do you not test the JavaScript behavior with a simple button containing this formula:
@Command([ViewRefreshFields])

If the values come back from Domino with the values you expect, then you can be sure Domino will also save this fields as presented to browser.

0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Go on Groove i am there !
0
 
LVL 10

Accepted Solution

by:
zvonko earned 150 total points
Comment Utility
OH, one more.

Perhaps are you irritated by InternetExplorer and its dammed cache :-)

Try reload :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Look at my first comment !!!
0
 

Author Comment

by:GaryZ
Comment Utility
Yes, it is the cache that is now causing the problem (arunkumar - your first answer was not the initial problem)

Zvonko - I can give you the points for this question, and start another question if you like.

Here is what my problem is now:

I created a function to reload the frame and move the correct values (based on location to the field), however, the form just keeps reloading, and I am getting a permission denied message.

In the onload I have the following:

f=document.forms[0];
var maindoc = parent.frames[0].document.forms[0];
parent.nav.window.location='/BOP.nsf/LinkBar?Open&R=' + maindoc.Rated_Quote.value  ; +
LoadValues();


The LoadValues() is the following.


function LoadValues()
 {
     location.reload()
     alert(document.forms[0].mF1_Desc1[0].value)
     alert(document.forms[0].mF1_Desc1[1].value)
     alert(document.forms[0].mF1_Desc1[2].value)
     alert(document.forms[0].Temp.value)
     document.forms[0].F1_Desc1.value = document.forms[0].mF1_Desc1[document.forms[0].LocationSub.value].value
}


Like I said I can post this as a new question if you want.














0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Hi Zvo!

:-)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Hay Gary,

for both is 150 point more then enough :-)

Cache is a trivia and endless loop is also a trivia :-)

Gary, you can not place into onLoad anywhere the function: location.reload()
This is an endless loop.............


Sorry, but sometimes you need somebody to say you such things. Because, as everybody, you read what you want to be there, and not what is really there :-)

Good luck,
zvonko

Hi Arun, I was all the Sunday not online. Sorry :)



0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Thats okay Zvo. What about the client language ???
0
 

Author Comment

by:GaryZ
Comment Utility
OK. As you can tell, I am new at this (JS). So how do I do a refresh?
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
You have to put the new frame request load action into onChange event of the field requesting the new frame.

I assume the field to which content you like to adjust the frames is: Rated_Quote

So you have either to move the code from onLoad to Rated_Quote onChange event, or, better idea, place the onLoad code in a new JavaScript function located in JSHeader form event and call this new function doing frame adjust from the appropriate fields onChange event.


0
 

Author Comment

by:GaryZ
Comment Utility
The final form has maybe 50 fields on it that will use this code. Some fields will have entries others not.

I tried the following code in the body of the form, but it kept reloading also, I guess this is the same problem.

<Script Language="JavaScript">
if((document.forms[0].NewDoc.value) == "N"  && (document.forms[0].Refresh.value == "0"))
{
    document.forms[0].Refresh.value = "1"
    location.reload(0)
    }
</script>
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
OK, 50 fields or not: when does the frame has to be reloaded?
Does the form already reload automatically and you need only frame adjustment?

0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Would it help when I could see your frames localy :-)
My email address is: zp@arcor.de

0
 

Author Comment

by:GaryZ
Comment Utility
The database is 1.6 meg without any documents in it. Do you still want it?
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Yes.

But please zip it before sending :-)

0
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Gary,

I already said that where the problem exists and still you are trying to complicate.

If you are not sure what to do, let me explain.

You Rate Quote button formula should include this line before submit,

document.forms[0].fDocID.value = mainform.UniqueKey.value

Your code in Edit Quote button goes like this.
@SetTargetFrame("main");
@URLOpen("http://" + Server_Name + "/" + DataBase + "/Lookup2/" + fDocID + "?EditDocument"  )

Where fDocID, is a computedfordisplay field with fDocID as the default value.

Check on the form property "Generate HTML for All fields"

Also the UniquKey field in top form should contain this formula @Unique to guarantee uniqueness.

And you are all set.
0
 

Author Comment

by:GaryZ
Comment Utility
GOT IT!!!!!!

To stop cacheing in IE you need to put the following code at the end of the form.

<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</head>
0
 

Author Comment

by:GaryZ
Comment Utility
Thanks. This is the code I used to create the fields.
0
 

Author Comment

by:GaryZ
Comment Utility
To actually solve the cacheing problem. I had to use a random number generator and attach the random number as a parameter to the end of the URL. Then IE was forced to go back to the server.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Thanks for the points :-)

0
 

Author Comment

by:GaryZ
Comment Utility
I thought I had already given them to you, when I came back in to ask another question, I discovered I hadn't. Sorry for the delay.
0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
As long you give it to Zvo its fine !

:-P
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

6 Experts available now in Live!

Get 1:1 Help Now