24-May-14 (Created: 24-May-14) | More in 'CS-JavaScript'

Another javascript example - checkboxes, arrays, strings, trim


String.prototype.trim = function() {

// skip leading and trailing whitespace
// and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}

function testCheckboxes()
{
	alert("hhhh");
	selRows = getSelectedCheckBoxValues(document.mainform,"my_checkbox",",");
	selRowsArray = selRows.split(",");
	if (selRowsArray.length == 0)
	{
		alert("No rows selected");
		return;
	}
	firstId = selRowsArray[0];

	alert("First selection before trim is:" + firstId + ":");
	
	firstId = firstId.trim();
	alert("First selection is:" + firstId + ":");
	
	//firstId now contains the key for the next page
}