SSJS - Server Side JavaScript
------------------------------------
Edit Box, Check Box, Radio Button, Radio Button Group:
getComponent("ControlID").value
Check Box group:
...
Setting SSJS Values
------------------------------------
Edit Box:
getComponent("ControlID").setValue("something");
______________________________________________
CSJS - Client Side JavaScript
Getting CSJS Values
------------------------------------
Edit Box, Combo Box, Radio Button:
XSP.getElementById("#{id:ControlID}").value
Check Box:
XSP.getElementById("#{id:ControlID}").checked //will return 'true' if checked, 'false' if not checked
Check Box Group:
var checkField=document.getElementsByName("#{id: ControlID }");
var result=[];
for(var i=0;i<checkField.length;i++){
if(checkField[i].checked){
result.push(checkField[i].value);
}
}
alert(result.join(','));
Radio Button Group:
var result=null;
for(var i=0; i<document.forms[0].elements.length; i++){
if(document.forms[0].elements[i].name=="#{id:ControlID}" ){
if(document.forms[0].elements[i].checked == true){
result=document.forms[0].elements[i].value;
break; //remove this if for check box groups and collect multiple values above instead
}}}
alert(result); //result is the currently selected value of the radio group
Setting CSJS Values
-----------------
Edit Box:
XSP.getElementById("#{id:ControlID}").value = "something";
Radio Button Group:
function setRadioValue(id, value)
{
var elements = document.getElementsByName (id);
for(i=0;i<elements.length;i++) {
if (elements[i].value == value) {
elements[i].checked = true;
}
}
}
setRadioValue("#{id:radioGroup}", "value");