HTML Connect User's Guide
APPENDIX E
// These ECMAScript functions are invoked from Function Actions created
// in the HTML Connect when a user makes certain selections on HTML FORM
// based visual controls.
/**********************************************************/
// Functionname: removeSelectedAttr(nodelist)
// Description: removes 'selected' attribute from a control
// nodelist: is required, the list of nodes to remove attribute from
// Returns: void
// Note: Uses DOM Element methods getAttribute()
// and removeAttribute()
/**********************************************************/
function removeSelectedAttr(nodelist)
{
for(var elem in nodelist)
{
var attr = elem.getAttribute("selected");
if(attr != null)
elem.removeAttribute("selected");
}
}
/**********************************************************/
// Functionname: updateSelectedAttr(nodelist, asRExpr)
// Description: Method to update list selection for a COMBO BOX. A Combo Box can
// have one value selected. This method compares the passed in
// expression and creates selected attr for the one element whose
// attribute matches the passed in param and removes selected attr
// for the rest of the items, in case they have selected attr present
// nodelist: is required, is the list of option nodes
// asRExpr: is required, is the right hand side expression
// Returns: void
// Note: Uses DOM Element methods getAttribute() and removeAttribute()
/******************************************************************/
function updateSelectedAttr(nodelist, asRExpr)
{
for(var elem in nodelist)
{
// get the node value. Call back exteNd
var lVal1 = Packages.com.sssw.b2b.rt.GNVXMLDocument.getNodeStringValue(elem);
// trim leading and trailing blanks on both side of the expressions
// before comparison
var lVal = new java.lang.String(lVal1);
lVal = lVal.trim();
var rVal = new java.lang.String(asRExpr);
var rVal = rVal.trim();
if(lVal == rVal)
elem.setAttribute("selected", "selected");
else
{
var attr = elem.getAttribute("selected");
if(attr != null)
elem.removeAttribute("selected");
}
}
}
/**********************************************************/
// Functionname: removeCheckedAttr(nodelist)
// Description: Method to remove 'checked' attribute for RADIO BUTTONS,
// CHECKBOXES, PUSH BUTTONS etc.
// nodelist: (required) list of nodes for which 'checked' attr needs
// to be turned off.
// Returns: void
// Note: Uses DOM Element methods getAttribute()
// and removeAttribute()
/*********************************************************/
function removeCheckedAttr(nodelist)
{
for(var elem in nodelist)
{
var attr = elem.getAttribute("checked");
if(attr != null)
elem.removeAttribute("checked");
}
}
***************************************************/
// Functionname: toggleListSelectedAttr(elem, asValue, abAddAttr)
// Description: Method to create selected attribute
// for a MULTI-SELECTION LIST BOX in case the boolean
// passed in param abAddAttr is true, and
// remove selected attr in case abAddAttr is false.
// elem: DOM element for which 'selected' attr is either to be
// created or removed.
// asValue: value to be matched for the 'option' desendant element.
// abAddAttr: boolean. When true, creates 'selected' attr
// for the 'option'
// element for which the value matched with
// asValue and removes
// 'selected' attr in the event the flag is false.
// Returns: void
// Note: Uses DOM Element methods getAttribute()
// and removeAttribute()
/*********************************************************/
function toggleListSelectedAttr(elem, asValue, abAddAttr)
{
// find all descendant elements by the name 'option'
var lOptionList = elem.getElementsByTagName("option");
for(var child in lOptionList)
{
// get value attr for the child
var lsChildAttrVal = child.getAttribute("value");
if(lsChildAttrVal == asValue)
{
// for the child whose value matches passed in value,
// create attr in case abAddAttr is true or remove otherwise
if(abAddAttr == true)
{
child.setAttribute("selected", "selected");
}
else
{
child.removeAttribute("selected");
}
break;
}
}
}
Copyright © 2004 Novell, Inc. All rights reserved. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved. more ...