:: Forum >>

Get Combo Box Value From Button

Assume I have:

var obj = new AW.UI.Combo();
obj.setId("staffCombo");
obj.setItemCount(myStaffVals.length);
obj.setItemText(myStaffVals);
obj.setItemValue(myStaffKeys);
document.write(obj);

and

var obj = new AW.UI.Button();
obj.setId("staffAdd");
obj.setControlText("Add Staff To Location");
obj.onControlClicked = function(event) {
window.location = "/wv_dev/client/addCommssionedStaff.asp?LID=<%= Request("LID") %>&PID=<%= Request("PID") %>&SID=";
};
document.write(obj);

How do I access the current, selected value of staffCombo in the onControlClicked of staffAdd?

Thanks.
Paul Tiseo
Thursday, April 6, 2006
It's nice to be able to provide support to yourself!

var staffCombo = new AW.UI.Combo();
staffCombo.setId("staffCombo");
staffCombo.setItemCount(myStaffVals.length);
staffCombo.setItemText(myStaffVals);
staffCombo.setItemValue(myStaffKeys);
// make combo more <select>-like
staffCombo.getContent("box/text").setAttribute("readonly", true);
staffCombo.onControlEditStarted = function() {
this.getContent("box/text").element().contentEditable = false;
}
document.write(staffCombo);


and

var staffAdd = new AW.UI.Button();
staffAdd.setId("staffAdd");
staffAdd.setControlText("Add Staff To Location");
// button click action
staffAdd.onControlClicked = function(event) {
var sel_val = staffCombo.getItemValue(staffCombo.getSelectedItems());
window.location = "/wv_dev/client/addCommissionedStaff.asp?LID=<%=Request("LID") %>&PID=<%= Request("PID") %>&SID=" + sel_val;
};
document.write(staffAdd);


Caveat: Not sure if my code in onControlClicked is the best way to trigger a page change. Probably there is a more AW way of doing this via Button properties and methods that I have yet to discover...
Paul Tiseo
Friday, April 7, 2006
Please correct the first line in the onControlClicked block for the button to:

var sel_val = myStaffKeys[staffCombo.getSelectedItems(staffCombo.getSelectedItems())];

This gets the actual <option> value, what I call the "key". The code in the above post gets you the position of the data of the combo in the array used to populate it.

My bad. Sorry.
Paul Tiseo
Friday, April 7, 2006

This topic is archived.


Back to support forum

Forum search