nickmagus Posted August 4, 2008 Share Posted August 4, 2008 hey so i have this java script i put into my header with an addHeader function i wrote but it doesn't work the target of the script is in a table when i take it out of the table it works whats with that? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted August 4, 2008 Share Posted August 4, 2008 Code example??? Also I assume you mean JavaScript; rather than a script, coded in Java (which is what it sounded like to me). Quote Link to comment Share on other sites More sharing options...
nickmagus Posted August 4, 2008 Author Share Posted August 4, 2008 so i have this function: function findObj(n, d) { var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } that is supposed to find objects by IDs but findObj('countrySelect') does not work for some reason. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 4, 2008 Share Posted August 4, 2008 Because that function expects two arguments and you are only giving it one. Quote Link to comment Share on other sites More sharing options...
nickmagus Posted August 4, 2008 Author Share Posted August 4, 2008 no it should work still because of the line: if(!d) d=document; which should set d to document if no d is given. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted August 4, 2008 Share Posted August 4, 2008 function findObj(n, d=FALSE) { var p,i,x; if(!d || d=FALSE) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } ??? Quote Link to comment Share on other sites More sharing options...
nickmagus Posted August 5, 2008 Author Share Posted August 5, 2008 nope didn't work does this code search by the element name or its id? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.