Yes, I have some. First, you should write HTML DOM accessors
case-insensitive (use RegExp matching for that). Second, you should return
a value different from `undefined' in the "select-multiple" case. Third,
you may use switch...case instead of if..else if. Fourth, identifiers that
don't refer to constructors should not start with a capital letter to keep
the distinction.
Finally, please trim your quotes to the necessary minimum.
http://jibbering.com/faq/
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
My other two functions used in the function mentioned:
function isArray(a){
if(!a||typeof(a)!=='object'||!a.hasOwnProperty)return false;
if(typeof(a.length)!=='number'||
a.propertyIsEnumerable('length'))return false;
return (a instanceof Array);
}
function inArray(a,v,s){
if(!isArray(a)||a.length==0)return false;
if(typeof(v)=='string'||typeof(v)=='number'){
if(s===1){
for(var z=0;z<a.length;z++){
if(a[z]===v){
return true;
}
}
}else{
for(var z=0;z<a.length;z++){
if(a[z]==v){
return true;
}
}
}
}
return false;
}
for `1st, I should re-consider whether to check the values match by
case-insensitive or case-sensitive; `2nd, if the second parameter is
not given, it should just do selectRef.selectedIndex=-1 that set the
select elem not select nothing, and for `select-multiple', the values
should be in a [Array] to be checked with; `3rd, I never consider
which is better switch ... case... and if ... else ... ; `4th, do you
mean I'd better use inarray and isarray instead of inArray and
isArray? Perhaps it is just the way I`m used to writing scripts. May
be I should avoid doing that; at last, I think I should write more
neat and strict scripts.
Thanx again for your reply.