Question : Delimited text to array in jscript

hi,

i have this function definition:
 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function xtoggleDisplay(aid, atagname, aclassname, adisplayvalue) {
  var obj = document.getElementById(aid);
  var elements = obj.getElementsByTagName(atagname);
  for (var i = 0; i < elements.length; i++) {
	if ((aclassname == '') || (elements[i].className == aclassname)) elements[i].style.display = adisplayvalue;
  }
}
function xtoggleOn(aid, atagname, aclassname) {
  xtoggleDisplay(aid, atagname, aclassname, '');
}
function xtoggleOff(aid, atagname, aclassname) {
  xtoggleDisplay(aid, atagname, aclassname, 'none');
}


i have this onclick event:
 
1:
onclick="xtoggleOff('tbl_data_1', 'tbody', ''); xtoggleOff('tbl_data_1', 'tr', '');"


i'd like to able to set the onclick like this:
 
1:
xtoggleOff('tbl_data_1', 'tbody;tr', '');


it's like creating a array from a delimited string
how can i do that ?

Answer : Delimited text to array in jscript

you can easily pass the comma separated string and then convert it into an array using
split method String
http://www.w3schools.com/jsref/jsref_split.asp

Let me know if this helps
Random Solutions  
 
programming4us programming4us