RE: Need help to display the prompt box using javascript on web Matt Pethig 2.Aug.17 05:22 PM a Web browser Domino Designer All ReleasesAll Platforms
This may also help you get started. I had a form where I wanted the admins to be able to select a user to remove from a Business Case and the reason for removal, so there are two questions asked in the prompts in this snippet. My prompt form is called RemoveUser and when I open it I pass it &users=message.
message is just a variable that I set earlier in the code and is used to set the options for the list of users that are currently listed on the document, so it is dynamic as the list displayed will be different for each Business Case
Main Form action button
.....rest of code
var pathname = (window.location.pathname);
var retval = window.showModalDialog(pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+'RemoveUser?OpenForm&users=' + message,"" ,"dialogWidth: 630px;dialogHeight: 480px;status: yes;unadorned: yes;scroll: yes;help: no;resizable: yes;");
...rest of code
The retval variable is set by window.returnValue in the second OK button. I had two return values seperated by a newline character so I split on the newlines and then had two values that I could set fields to in the Main form
RemoveUser Form
OK Button 1 - user variable is a global so value is set in first OK button and retrieved in second OK button
var f = document.forms[0];
var selection = false;
var numberselected = 0;
var chosen = 0;
for (i = 0; i < f.UserList.length; i++)
{
if (f.UserList.options[i].selected == true)
{
//one option must be selected or error message displayed
selection = true;
//field is set to multi value for display purposes but only one user can be selected
numberselected++;
//store option selected which will be returned to parent window
chosen = i;
}
}
if (selection == false)
{
alert ("Please select the user to remove from the Business Case");
f.UserList.focus();
return;
}
if (numberselected > 1) {
alert ("You can only select one user to remove from the Business Case");
f.UserList.focus();
return;
}
OK Button 2
var f = document.forms[0];
var selection = false;
var chosen = 0;
for (i = 0; i < f.Reason.length; i++)
{
if (f.Reason[i].checked == true)
{
//one option must be selected or error message displayed
selection = true;
//store option selected which will be returned to parent window
chosen = i;
}
}
if (selection == false)
{
alert ("Please select the reason for removing from the Business Case");
f.Reasonfocus();
return;
}
window.returnValue = user + "\n" + f.Reason[chosen].value;
window.close();