Geert G
asked on
Delimited text to array in jscript
hi,
i have this function definition:
i have this onclick event:
i'd like to able to set the onclick like this:
it's like creating a array from a delimited string
how can i do that ?
i have this function definition:
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:
onclick="xtoggleOff('tbl_data_1', 'tbody', ''); xtoggleOff('tbl_data_1', 'tr', '');"
i'd like to able to set the onclick like this:
xtoggleOff('tbl_data_1', 'tbody;tr', '');
it's like creating a array from a delimited string
how can i do that ?
ASKER
it's in the small print ...
now i call a procedure xtoggleOff twice for 2 different tagName's (tbody and tr)
i'd like to be able to call xtoggleOff only once, but pass it both tagName's in 1 string
using a delimited string
the code xtoggleDisplay would have to change for this to work:
function xtoggleDisplay(aid, atagname, aclassname, adisplayvalue) {
var obj = document.getElementById(ai d);
var elements = obj.getElementsByTagName(a tagname);
this is the problem i can't solve:
var classnames = stringtoarray(aclassname);
change to something like below
now i call a procedure xtoggleOff twice for 2 different tagName's (tbody and tr)
i'd like to be able to call xtoggleOff only once, but pass it both tagName's in 1 string
using a delimited string
the code xtoggleDisplay would have to change for this to work:
function xtoggleDisplay(aid, atagname, aclassname, adisplayvalue) {
var obj = document.getElementById(ai
var elements = obj.getElementsByTagName(a
this is the problem i can't solve:
var classnames = stringtoarray(aclassname);
change to something like below
function xtoggleDisplay(aid, atagname, aclassname, adisplayvalue) {
var obj = document.getElementById(aid);
>> var classnames = stringtoarray(aclassname);
var elements = obj.getElementsByTagName(atagname);
function xtoggleDisplay(aid, atagname, aclassname, adisplayvalue) {
var obj = document.getElementById(aid);
>> var classnames = stringtoarray(aclassname);
var elements = obj.getElementsByTagName(atagname);
for (var i = 0; i < elements.length; i++) {
x = 0;
if (aclassname == '') x=1;
>> for (var j=0; j < classnames.length; j++) {
>> if (elements[i].className == classnames[j]) x=1;
>> }
if (x == 1) elements[i].style.display = adisplayvalue;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
exactly what i was looking for !
and a reference to the basics of JScript also.
Now i can really dig in.
Thanx
and a reference to the basics of JScript also.
Now i can really dig in.
Thanx
thanks for the points :)
ASKER
sometimes i wonder why i look for things myself
and not ask a question straight away in the appropriate TA
I spent more than an hour trying to find a JScript reference on MSDN library.
I could have had it in 10 minutes as this Q proves again.
Thanx for the fast response.
and not ask a question straight away in the appropriate TA
I spent more than an hour trying to find a JScript reference on MSDN library.
I could have had it in 10 minutes as this Q proves again.
Thanx for the fast response.
how can i do that ?>>
pardon my ignorance, but didn't quite get the meaning of this, could you please rephrase?
Also please mention what is the problem that you are facing.
Thanks