logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 05-17-2009, 06:46 AM   #1
bugfinder
bugfinder's Avatar
 
Join Date: May 2009
Location: Kuwait
Posts: 5
Question selected is null or not an object

Good day everybody i have issue with my code, i get error "selected is null or not an object " Line 128 and 155 can anyone check this for me .. im usig IE 6

Code:
<?
    include('config.php');
    include('connect.php');
    include('checkusersession.php');
    if (!isset($target_type))
        $target_type = 'all';    
?>
<form  name='form_allocate_terminals'>
<table  border="0" cellpadding="4" cellspacing="4" width="50%" align="center" class="tableForm">
 <tr >
         
        <td align="left" valign="middle" width="3%" >                        
            <font color="#000000"><strong>Type:</strong></font>       
        </td>
        <td align="left" valign="middle"   colspan="5">
           <select name="message" >
            <?
                $sqlMsg = "SELECT * FROM `".$DBTablesPrefix."_emergency_type`";
                $Infos = mysql_query($sqlMsg) or die("Query Failed 1");
                $j = 0; 
                while($Row_Infos = mysql_fetch_assoc($Infos)) 
            {
                $j++;
                $Id = $Row_Infos['Id'];
                $name = $Row_Infos['name'];
                echo "<option value='".$Id."' ".$strSelected.">".$name;
            }
            ?>
           </select>            
        </td>
  </tr>    
  <tr bgcolor="#ECECEC" >
            <td align="left" valign="middle" width="3%" colspan="4">
            <input type="radio" name="target_type" value="all" <?=($target_type=="all")?"checked":""?> onClick="disableItems(this);">
            <font color="#000000" size="2"><strong>All</strong></font>
        </td>    
   </tr>   
   <tr bgcolor="#ECECEC">
            <td align="left" valign="middle" width="3%" colspan="4">
            <input type="radio" name="target_type" value="room" <?=($target_type=="room")?"checked":""?> onClick="disableItems(this);">
            <font color="#000000" size="2"><strong>Rooms</strong></font>
        </td> 
    </tr>
    <tr >
         <td align="left" valign="middle" width="30%">
          <select name="target_list[]" id ='target_list' size="3" multiple style="width:100 ">
            <?
                    //terminal identification in multi-terminal rooms
                $query ="SELECT IP, Room FROM `".$DBTablesPrefix."_stbs`"."WHERE Version='aminet110' "." ORDER BY Room ";
                 $Infos = mysql_query($query) or die("Query failed on line 188");
                $i = 0;
                while($Row_Infos = mysql_fetch_array($Infos))
                    {
                    $i++;
                    $IP     = $Row_Infos['IP'];
                    $Room     = $Row_Infos['Room'];                        
                    $messRoom = Room; 
                    //echo "<option value='".$Room[$i]."' ".$strSelected.">".$Room."::".$IP."\r\n";
                  echo "<option value='".$Room[$i]."' ".$strSelected.">$messRoom ".$Room." \r\n";
                    }
             ?>
          </select>
</td>
        <td  width="10%" align="center" valign="middle">
            <input type="hidden" name="action" value="add">
             <table  border="0">                 
                <tr align="center" height="50%">
                      <td width="30%">
                        <?
                        echo '<img src="../admin/img/right.gif"  border="0"><img src="../admin/img/right.gif"  border="0">';
                        ?>
                     </td>
                     <td>
                    
                    <input type="button" onClick='movein()' value="Add">
                    
                     </td>
                    <td width="30%">
                    <?
                     echo '<img src="../admin/img/right.gif"  border="0"><img src="../admin/img/right.gif"  border="0">';
                     ?>                                                                
                    </td>
               </tr>
                 <tr align="center" height="50%">
                    <td width="30%">
                        <?
                            echo '<img src="../admin/img/left.gif"  border="0"><img src="../admin/img/left.gif"  border="0">';
                        ?>
                    </td>
                    <td>
                    <input type="button" onClick="moveout()" value="Remove">
                    </td>
                    <td width="30%"><? echo '<img src="../admin/img/left.gif"  border="0"><img src="../admin/img/left.gif"  border="0">';?>
                    </td>                                                                
                 </tr>
          </table>                           
      </td>
        
          <td align="right" width="30%">
           <select name="allocatedTerminals[]" id='allocatedTerminals' size="3" multiple style="width:100 " >                    
        
            </select>
      </td>
 </tr>
  <tr align="center" >
    <td colspan="4"><input type="button" name='btnSend' value="Send" onClick="sendemergency(form_allocate_terminals)">
     <!-- <input name="btnsend"  type="button" class="buttform" id="34" value="Send Emergency" onclick="pushpage()" />--></td>
  </tr>                                                        
 </table>                                   
</form>
<script language="javascript">
var cmdLink = "EMERGENCY_execcommand.php?Emergency=<?php echo $name;?>&targetType=<?php echo $target_type;?>&ip=<?php echo $IP;?>";
function pushpage()
{
    Link = cmdLink+" SEND";
    //alert(Link);
    var msg = "Are you sure you want to delcare Emergency?";
    if(confirm(msg))
        document.location.href=""+Link;
}
function movein()
{
    var target_list = document.getElementById('target_list');;
    var allocated_terminal = document.getElementById('allocatedTerminals');
    var target_list_length = target_list.length;
    for(var j=0; j<target_list_length; j++)
    {
        if(target_list[j].selected)    //this is where im getting error msg 
        {
            var tmp = target_list.options[j].text;
            var tmp1 = target_list.options[j].value;
            target_list.remove(j);
            j--;
            var y=document.createElement('option');
            y.text=tmp;
            try
            {
            allocated_terminal.add(y,null);
            }
            catch(ex)
            {
            allocated_terminal.add(y);
            }
        }
    }
}

function moveout()
{
    var target_list = document.getElementById('target_list');
    var allocated_terminal = document.getElementById('allocatedTerminals');
    var allocated_terminal_length = allocated_terminal.length;
    for(var j=0; j<allocated_terminal_length; j++)
    {
        if(allocated_terminal[j].selected)    //this is where im getting error msg 
        {
            var tmp = allocated_terminal.options[j].text;
            var tmp1 = allocated_terminal.options[j].value;
            allocated_terminal.remove(j);
            j--;
            var y=document.createElement('option');
            y.text=tmp;
            try
            {
            target_list.add(y,null);
            }
            catch(ex)
            {
            target_list.add(y);    
            }

        }
    }    
}

function disableItems(selectedItem)
 {
    if (selectedItem.value =='all')
        {
              document.getElementById("target_list").disabled = true;
            document.getElementById("allocatedTerminals").disabled = true;
                    
        }
    else  if(selectedItem.value =='room')
        {
            document.getElementById("target_list").disabled = false;        
            document.getElementById("allocatedTerminals").disabled = false;
            
        }            
 }
window.onload=function()
 {
    var targetType = '<? echo $target_type;?>';
    if (targetType =='all')
        {
            document.getElementById("target_list").disabled = true;
            document.getElementById("allocatedTerminals").disabled = true;
                    
        }
    else  if(targetType =='room')
        {
            document.getElementById("target_list").disabled = false;        
            document.getElementById("allocatedTerminals").disabled = false;
            
        }        
 }    
 

function sendemergency()
{
var len =document.form_allocate_terminals.target_type.length;
for (i=0;i<len;i++)
{
if(document.form_allocate_terminals.target_type.checked)
 {
 alert("Do you really want to send the emergency");
 }
}
}
</script>
<?php

    $action =send;     
    if ($btnSend ==$action)
    {
        $pause = 5;
        $sqlMsg = "SELECT * FROM `".$DBTablesPrefix."_emergency_type`";
        $Infos = mysql_query($sqlMsg) or die("Query failed on line 55");
        $j = 0;
        while($Row_Infos = mysql_fetch_assoc($Infos))
        {    
            $j++;
            $Id= $Row_Infos['Id'];
            $msg= $Row_Infos['message'];
            if ($Id == $message)
            {
                $display_message = $msg;
            }    
        }
        $commandURL = "../emergency/simple_remote_control.php?message=".urlencode(stripslashes($display_message));
        $cmdOptions = "/PASSWORD \"".$aminoRemoteControlPassPhrase."\" /TIMEOUT 12 /THREADS 60 /PAUSE ".$pause." /QUIET";
        $cmdCommand = "/LOADURL ".EMERGENCY_PATH."simple_emergency_message.php"."?message=".urlencode(stripslashes($display_message));
        $cmdFile = "/FILE \"".$tIpListFiles[$TERM_TYPE_AMINET100][0]."\"";    
        if ($target_type == 'all')    
        {
            $sqlTerminals =    "SELECT IP, Room FROM `".$DBTablesPrefix."_stbs`"." 
            WHERE Version='AMINET110'  "."ORDER BY (Room+0)";
            $Infos = mysql_query($sqlTerminals) or die("Query failed on line 78");
            $i = 0;
            while($Row_Infos = mysql_fetch_assoc($Infos))
            {
                $i++;
                $termIP     = $Row_Infos['IP'];
                $termRoom     = $Row_Infos['Room'];    
                $cmdLine     = "AminoBatchControl.exe ".$cmdCommand." ".$cmdOptions." ".' TERMINALCHANGE '.$termIP;
                exec( $cmdLine, $cmdOutput);
            }    
        }
        
        else if ($target_type == 'room')    
        {
            for ($i = 0; $i< count($Room); $i++)
            {
                $sqlTerminals =    "SELECT IP, Room FROM `".$DBTablesPrefix."_stbs` ". "WHERE `Room` = '$Room[$i]'";        
                $Infos = mysql_query($sqlTerminals) or die("Query failed in line 95");
                   if ($sqlTerminals > 0)
                while($Row_Infos = mysql_fetch_assoc($Infos))
                {
                    $IP_terminal     = $Row_Infos['IP'];                
                    $cmdLine = "AminoBatchControl.exe ".$cmdCommand." ".$cmdOptions." ".' TERMINALCHANGE '.$IP_terminal;
                    //echo $cmdLine;
                    exec( $cmdLine, $cmdOutput );
                }
            }        
        }
    }
?>
thanks in advance
bugfinder is offline   Reply With Quote
Old 05-18-2009, 03:35 AM   #2
domedia
Administrator
domedia's Avatar
 
Join Date: Dec 2003
Posts: 9,730
Default

The error is from your browser, so you have to provide the code that is sent to the browser after PHP is parsed.
domedia is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:52 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com