• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1030
  • Last Modified:

JavaScript to change Dialog list

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
GaryZ
Asked:
GaryZ
  • 11
  • 9
  • 6
  • +1
1 Solution
 
ArunkumarCommented:
After setting the value are you doing a refresh on the document ?  Try that !
0
 
HemanthaKumarCommented:
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
 
zvonkoCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
GaryZAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
GaryZAuthor Commented:
Thanks I emailed a really stripped down database to you.
0
 
HemanthaKumarCommented:
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
 
HemanthaKumarCommented:
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
 
GaryZAuthor Commented:
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
 
zvonkoCommented:
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
 
ArunkumarCommented:
Go on Groove i am there !
0
 
zvonkoCommented:
OH, one more.

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

Try reload :-)

0
 
ArunkumarCommented:
Look at my first comment !!!
0
 
GaryZAuthor Commented:
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
 
ArunkumarCommented:
Hi Zvo!

:-)
0
 
zvonkoCommented:
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
 
ArunkumarCommented:
Thats okay Zvo. What about the client language ???
0
 
GaryZAuthor Commented:
OK. As you can tell, I am new at this (JS). So how do I do a refresh?
0
 
zvonkoCommented:
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
 
GaryZAuthor Commented:
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
 
zvonkoCommented:
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
 
zvonkoCommented:
Would it help when I could see your frames localy :-)
My email address is: zp@arcor.de

0
 
GaryZAuthor Commented:
The database is 1.6 meg without any documents in it. Do you still want it?
0
 
zvonkoCommented:
Yes.

But please zip it before sending :-)

0
 
HemanthaKumarCommented:
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
 
GaryZAuthor Commented:
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
 
GaryZAuthor Commented:
Thanks. This is the code I used to create the fields.
0
 
GaryZAuthor Commented:
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
 
zvonkoCommented:
Thanks for the points :-)

0
 
GaryZAuthor Commented:
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
 
ArunkumarCommented:
As long you give it to Zvo its fine !

:-P
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 9
  • 6
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now