Current location: Hot Scripts Forums » General Web Coding » JavaScript » selected is null or not an object


selected is null or not an object

Reply
  #1 (permalink)  
Old 05-17-09, 01:41 AM
bugfinder bugfinder is offline
New Member
 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation selected is null or not an object

Good day everybody, i have a issue with my code i get "selected is an null or not an object can any one check this for me ...

line 128 and 155
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
Reply With Quote
  #2 (permalink)  
Old 05-17-09, 06:46 AM
Vicious's Avatar
Vicious Vicious is offline
Community VIP
 
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
You have written this
Code:
if(target_list[j].selected)
While it should be this
Code:
if(target_list.options[j].selected)
You want to check if the option was selected, not the "j-th" attribute of your selectbox.
__________________
Jack Bauer makes Chuck Norris cry
Reply With Quote
  #3 (permalink)  
Old 05-17-09, 09:01 AM
bugfinder bugfinder is offline
New Member
 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
i edited my code with ur still i get the same error ..!!!

Error:-options[...].selected is null or not an object.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keypad Login smithygotlost Script Requests 26 07-11-07 12:29 PM
MYSQL database countll Database 2 06-19-07 04:20 PM
What do you think of my database structure? Oskare100 Database 5 12-27-06 07:43 AM
Left Join with Where & Count is eluding me CutAndPaste PHP 8 12-13-05 03:46 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM


All times are GMT -5. The time now is 01:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.