Page 1 of 1

object required

Posted: Wed Aug 13, 2003 3:26 am
by zuzupus
hi,
i got problem while running this file as javascript error as object required dont no why hopefull help me out
http://172.16.0.100/scripts/test.phtml

my code is mix of PHP and javascript

Code: Select all

<? $dir = './'; require($dir.'lib.php'); get_session(); ?>
    
<html>
   <head>
     
                <title>Upload</title>
                <link rel="stylesheet" type="text/css" href="../styles/styles.css" />
                <? if ($session->active != $active || $active) &#123; ?>
            <script language="JavaScript" type="text/javascript">
                                <!--
                                        <?
                                          if ($active && $mayRead) &#123;
                                         list($info, $html_file) = once_query_array("SELECT info, html_file FROM t_directories WHERE sys_pk = $active");
                                        if (is_true($info)) &#123;
                                        ?>
            parent.frames&#1111;'content'].location.replace('../htm/<?=addslashes($html_file ? "infos/$html_file" : "empty.htm") ?>');
                    <? &#125; else &#123; ?>
          parent.frames&#1111;'content'].location.replace('filelist.phtml?type=<?=(($rights == 2) ? 1 : 0) ?>&tree=<?=$active ?>');
                  <? &#125; &#125; else &#123; ?>
          parent.frames&#1111;'content'].location.replace('blank.phtml');
                   <? &#125; ?>
            function saveScrollPosition() &#123;
                         var scrollY;
                         if (window.innerHeight)
                         &#123;
                             scrollY = window.pageYOffset
                           &#125;
         if (document.all)
        if (document.documentElement && document.documentElement.scrollTop)
               &#123;
         scrollY = document.documentElement.scrollTop;
            &#125;
            else if (document.body)
              &#123;
            scrollY = document.body.scrollTop;
                  &#125;
                else
            scrollY = window.pageYOffset;
                parent.scrollY = scrollY;
                 &#125;
             function scrollWindow() &#123;
                window.scrollTo(0, parent.scrollY);
                                         &#125;
                                // -->
                        </script>
                <? &#125; ?>
                <?
                        $session->active = $active;
                ?>
        </head>
        <body class="gray">
                <table border="0" cellpadding="0" cellspacing="0" height="95%" width="100%">
                        <tr>
                                <td valign="top" align="left">
                                        
                     <?
                       function showTree($id, $level) &#123;
                       global $tree, $session, $active;
                   $var = is_array($tree&#1111;$id]) ? $tree&#1111;$id] : array();
                    foreach($var as $pk => $name) &#123;
                    if ($name&#1111;0] == chr(1)) &#123; $new = true; $name = substr($name, 1); &#125; else $new = false;
                   if ($name&#1111;0] == '+' || $name&#1111;0] == '-')
                   $link = 'href="'.htmlentities("test.phtml?flip=$pk&close=".($session->open&#1111;$pk] ? 1 : 0)).'"';
                  else
                     $link = 'href="'.htmlentities("test.phtml?active=$pk").'"';
                    ?>
                    
<p class="h<?=(($level > 4) ? 7 : ($level+3)) ?>"><?=str_repeat('&nbsp;', $level*3) ?><a onclick="saveScrollPosition();" class="h<?=(($level > 4) ? 7 : ($level+3)) ?>" <?=$link ?>><?=(($active == $pk || $new) ? '<span class="'.($active == $pk ? 'white' : 'newfiles').'">' : '') ?><?=htmlentities($name) ?><?=(($active == $pk || $new) ? '</span>' : '') ?></a></p>
                    
     <?
                        if ($session->open&#1111;$pk])
                          showTree($pk, $level+1);
                                   &#125;
                            &#125;
                  showTree(0, 0);
        ?>
                                </td>
                        </tr>
                        
                        
                </table>
                 <script language="JavaScript" type="text/javascript">
                         <!--
                                 setTimeout("scrollWindow();", 20);
                         // -->
                 </script>
        </body>
</html>

thanks in advance

Posted: Sun Aug 17, 2003 6:31 am
by patrikG
I'd advise ditching IE as development tool - use Mozilla Firebird, you get much more detailed error-messages.

Posted: Sun Aug 17, 2003 6:46 am
by patrikG
btw. got a gateway timeout when I tried to have a look at your page.

Posted: Mon Aug 18, 2003 3:00 am
by zuzupus
Thanks alot its very much appreciable for response i get rid of jscript object problem but get struck with another one regarding scrolling postion for tress when i click soem child or parent trees the scroller goes up everytime and i have to scroll down to see particular tree in short i cant see the tree in frame when i clciked the scroller jumps up,thats why i used below code from http://www.xs4all.nl/~ppk/js/fixedmenu.html

Code: Select all

function saveScrollPosition() {
     var scrollY;
   if (document.all) {
              if (window.innerHeight){
                                    scrollY = window.pageYOffset
                                                }
    else if (document.documentElement && document.documentElement.scrollTop){
                  scrollY = document.documentElement.scrollTop
                                                }
                    else if (document.body){
                           scrollY = document.body.scrollTop
                                                }
                     else{
                       scrollY = window.pageYOffset;
                         parent.scrollY = scrollY;
                    temp = setTimeout('scrollWindow()',20);
                           }
                   }
                                         }
       function scrollWindow() {
                          window.scrollTo(0, parent.scrollY);
                                      }

Code: Select all

<p class=\\"h<?=(($level > 4) ? 7 : ($level+3)) ?>\\"><?=str_repeat('&nbsp;', $level*3) ?><a onclick=\\"saveScrollPosition();\\" class=\\"h<?=(($level > 4) ? 7 : ($level+3)) ?>\\" <?=$link ?>><?=(($active == $pk || $new) ? '<span class=\\"'.($active == $pk ? 'white' : 'newfiles').'\\">' : '') ?><?=htmlentities($name) ?><?=(($active == $pk || $new) ? '</span>' : '') ?></a></p>
hope this is enouth to understand,thanks once again for your sincere advice

regards

Posted: Mon Aug 18, 2003 3:04 am
by qartis

Code: Select all

<? if ($session->active != $active || $active) { ?>
.. tends to be frowned-upon by most serious PHP developers. PHP looks at this, and says to itself

Code: Select all

if 'active', of $session, isn't equal to $active, OR if $active has a value
Use brackets to be more specific (.. unless that's what you wanted it to do, in which case I'll just walk away slowly.. :))

Posted: Mon Aug 18, 2003 3:22 am
by zuzupus
sorry i didnt understand what you mean could you please be more clear or could u please modify the code


thansk for understanding

Posted: Mon Aug 18, 2003 3:31 am
by qartis
Well, what is that line of code supposed to do?

Code: Select all

<? if ($session->active != $active || $active) { ?>

Posted: Mon Aug 18, 2003 3:37 am
by zuzupus

Code: Select all

<? if ($session->active != $active || $active) { ?>
[/quote]

thanks qartis but i dont have such kind of code in posted code well now it works fine when i changed jscript

function saveScrollPosition() {
var scrollY;
if (window.innerHeight){
scrollY = window.pageYOffset
}
if (document.all) {
if (document.documentElement && document.documentElement.scrollTop){
scrollY = document.documentElement.scrollTop
}
else if (document.body){
scrollY = document.body.scrollTop
}
}
else{
scrollY = window.pageYOffset;
parent.scrollY = scrollY;
//temp = setTimeout('scrollWindow()',20);
}

}
function scrollWindow() {
window.scrollTo(0, parent.scrollY);
}

thanks qartis

Posted: Mon Aug 18, 2003 1:58 pm
by qartis
In the very top snippet of code, line 8.

Posted: Tue Aug 19, 2003 2:54 am
by zuzupus
[sorry patrik even i too dont understand why its used in this code as this php has written by someone and i have done only javascript when i use MOZILLA the jscript erroer 'object reqd' not shown but in IE6 it always shown jscript error,i slightly modify the code to not get scroll jump.

[JSCODE]

<script language="JavaScript" type="text/javascript">
function saveScrollPosition() {
var scrollY;
if (document.all)
if (document.documentElement)
scrollY = document.documentElement.scrollTop;
else
scrollY = document.body.scrollTop;
else
scrollY = window.pageYOffset;
parent.scrollY = scrollY;
}

function scrollWindow() {
window.scrollTo(0, parent.scrollY);
}
</script>
[/JSCODE]

thnaks

Posted: Fri Aug 22, 2003 2:47 am
by zuzupus
sorry for late response,i was just looking at code more precisely

<? if ($session->active != $active || $active) { ?>

$active is the variable that is passed when a directory is clicked.
$session->active saves the value of the currently highlighted/active
directory.

So when a directory gets clicked (after ||) or gets changed in any other
way like deselected (before ||) the code gets executed to reload the
right frame.

hope you understand

thanks