1
I'm not much of a javascript coder, but found it to be necessary in order to complete the new XoopsFormSelectUser class in XOOPS 2.2
What I am trying to doI have a lookup window (popup) where one can search for users and with a checkbox select the relevant user(s) from the search result.
I want those selected users to be added to the form in the calling page - i.e. a hidden field with the uid, a disabled text field with the user's name and a link to remove the user again.
I'm having some trouble figuring out how to capture the selected checkboxes and create form elements in the form in the calling window.
Some code var usercount = '.$count.';
function addUser(userInfos) {
var formDiv = window.opener.xoopsGetElementById("'.$_REQUEST['target'].'"+"div");
for (i=0; i<userInfos.length; i++) {
var uinfo = userInfos[i].split("^");
var nameDom = window.opener.createElement(input);
nameDom.setAtribute("name", "'.$_REQUEST['target'].'text");
nameDom.setAttribute("id", "'.$_REQUEST['target'].'"+"text"+usercount");
nameDom.setAttribute("type","text");
nameDom.setAttribute("size","15");
nameDom.setAttribute("maxlength","255");
nameDom.setAttribute("value",uinfo[1]);
formDiv.appendChild(nameDom);
}
window.close();
return;
}
function getSelectedCheckboxValues(checkbox) {
if (checkbox.length) {
var returnvalues = array();
for (var i = 0; i < checkbox.length; i++) {
if (checkbox[i].checked) {
returnvalues[] = chekbox[i].value;
}
}
return returnvalues;
} else {
return checkbox.value;
}
}
//In the lookup form's onSubmit:
addUser(getSelectedCheckboxValues(frmResults.chooseUser));
//frmResults is the ID of the form
//chooseUser is the ID of the checkbox
Anybody able to help?
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."
Cusix Software