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? Link to comment https://forums.phpfreaks.com/topic/118033-scripts/ 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). Link to comment https://forums.phpfreaks.com/topic/118033-scripts/#findComment-607218 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. Link to comment https://forums.phpfreaks.com/topic/118033-scripts/#findComment-607765 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. Link to comment https://forums.phpfreaks.com/topic/118033-scripts/#findComment-607871 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. Link to comment https://forums.phpfreaks.com/topic/118033-scripts/#findComment-607893 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; } ??? Link to comment https://forums.phpfreaks.com/topic/118033-scripts/#findComment-607914 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? Link to comment https://forums.phpfreaks.com/topic/118033-scripts/#findComment-608147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.