function moveSelectedItems(fromList, toList) {
moveOneWay(fromList, toList);
}
function moveOneWay(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrFvalues = new Array();
var arrTvalues = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrTvalues[i] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
arrTvalues[tLength] = fbox.options[i].value;
tLength++;
}
}
tbox.length = 0;
var c;
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrTvalues[c];
no.text = arrTbox[c];
tbox[c] = no;
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
guys, i am trying to simulate clicking on a javascript button that moves an item from one list to another list.
<a href="javascript:moveSelectedItems(document.report.fromList, document.report.toList)"><img src="../images/b-addList.gif"></a>
function moveSelectedItems(fromList, toList) {
moveOneWay(fromList, toList);
}
function moveOneWay(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrFvalues = new Array();
var arrTvalues = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrTvalues[i] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
arrTvalues[tLength] = fbox.options[i].value;
tLength++;
}
}
tbox.length = 0;
var c;
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrTvalues[c];
no.text = arrTbox[c];
tbox[c] = no;
}
}
how could i simulate clicking on that button using httpunit?
WebResponse response = wc.getCurrentPage();
WebForm wf = response.getFormWithName("Report");
WebForm.Scriptable wfs = wf.getScriptableObject();
-----not sure how to simulate the situation -----
wf.setParameter("fromList", ... ????
wf.setParameter("toList", ..... ????
wfs.submit();