How to check a select tag for value


How to check the existing data to the select tag…

i have attach a image to easily understand what iam saying.
The data in the AssignTo column must not be viewed on the Action column
which i use a select tag.

How can i accomplish this idea…


You would change your code which populates that select tag to not include the value in the assign to column. With no idea what code produces that image, it’s impossible to say anything more…

Thanks for the reply…

Here is my code…


  $pendtickets = array();
	 $selectTicketsQuery = mssql_query("Select * from tblTicket inner join tblAssign on tblTicket.TickNo=tblAssign.TicketNo and tblAssign .AssignTo!= '$_SESSION[username]' ");
	 while($pendticket = mssql_fetch_array($selectTicketsQuery)){
        $pendtickets[] = $pendticket;
	$newtickno=mssql_query("Select * from tblTicket where TickNo not in (select TicketNo from tblAssign)");
	 while($newticket = mssql_fetch_array($newtickno)){
        $newtickets[] = $newticket;

	$Assign= mssql_query("Select * from MISPIC ");
							while($AssignOption = mssql_fetch_array($Assign)){
							$AssignOptions[] = $AssignOption;
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />

	<script type="text/javascript" language="javascript" src="jquery./jquery.js"></script>
	<script type="text/javascript" language="javascript" src="jquery./jquery.dataTables.js"></script>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
		} );
	<script type="text/javascript" charset="utf-8">


<?php echo '<meta http-equiv="refresh" content="60;url="UnAssignticket.php">';?>
	  <style type="text/css">
form {
<body id="dt_example">
<table  BORDERCOLOR="#0B0B0B" border='1' bgcolor="#F5F5FA" width="100%"  align='center'>
	<td >
		<img src='img/pend.png'>
	<td align='center'>
		<div align='left' id="containerpend">
			<div id="demo">
				<table BORDERCOLOR="#0B0B0B"  frame="box" cellpadding="0" cellspacing="0" frame="box"  class="display" id="example"> 
					<th><a title="Ticket Number">Ticket No.</a></th>
					<th><a title="Ticket Create By">Create By</a></th>
					<th><a title="Ticket Create Date">Create Date</a></th>
					<th><a title="Date Assigned">Date Assigned</a></th>
					<th><a title="Problem Error">Problem Description</a></th>
					<th><a title="Ticket Assigned To">Assign To</a></th>
					<th><a title="User Action">Action</a></th>
					<?php	foreach($pendtickets as $pendticket) 
							<tr class="GradeA">
								<td class='center'><?php echo "<a href='viewassignticket.php?id={$pendticket['TickNo']}&uname={$pendticket['UserName']}' title='View Ticket'>".$pendticket['TicketNo']."</a>"?></td>
								<td class='center'><?php echo $pendticket['UserName'];?></td>
								<td class='center'><?php echo $pendticket['DateCreate'];?></td>
								<td class='center'><?php echo $pendticket['DateAssign'];?></td>
								<td class='center'><?php echo $pendticket['Category']." (".$pendticket['Subcat'].")"?></td>
								<td class='center'><?php echo $pendticket['AssignTo'];?></td>
								<td class='center'>
								<form  id='trans'  name="trans" class='trans'  action='forwardtick.php' method='POST' >
								<?php 	$_SESSION['ticketassign']=$pendticket['TicketNo']; 
										<select  name='Trans' onchange="Transferticket('<?php echo $pendticket['TickNo'];?>',$(this));">
											<option value="0">Please Select</option>
											<?php foreach($AssignOptions as $TransferOption){ 
											echo '<option value="', $TransferOption['MISPIC'], '">', $TransferOption['MISPIC'], '</option>'; }	
					<?php }	?>
					<th>Ticket No</th>
					<th>Create By</th>
					<th>Create Date</th>
					<th>Date Assigned</th>
					<th>Problem Description</th>
					<th>Assign To</th>
</table	>

<script type="text/javascript" charset="utf-8">
function Transferticket(ticket,uVal) {
    if (window.confirm('Transfer this ticket number ' + ticket + ' to ' + uVal.val())) {
var forms = document.getElementsByTagName('trans'),
for (i = 0; i < forms.length; i += 1) {
    if (forms[i].className === 'trans') {
        forms[i].onchange = Transferticket;

	<style type="text/css" title="currentStyle">
		@import "css/demo_page.css";
		@import "css/demo_table.css";

}else{ //not logged in
    header('location: login.php');

Report to moderator

Change this:

    $Assign= mssql_query("Select * from MISPIC ");

to this:

    $Assign= mssql_query("Select * from MISPIC WHERE MISPIC != '" . $pendticket['AssignTo'] . "'");

Though you should probably be escaping $pendticket[‘AssignTo’] before sticking it in a query if it can contain quotes or other literals you can’t put in a query.

Alternatively, in your loop:

                                            <?php foreach($AssignOptions as $TransferOption){ 
                                            echo '<option value="', $TransferOption['MISPIC'], '">', $TransferOption['MISPIC'], '</option>'; }  

skip printing if the name equals the person already assigned to

                                            <?php foreach($AssignOptions as $TransferOption){ 
                                            if ($TransferOption['MISPIC'] != $pendticket['AssignTo'])
                                                echo '<option value="', $TransferOption['MISPIC'], '">', $TransferOption['MISPIC'], '</option>'; }  

Thanks it works.i’am thinking outside the box.But i got a problem in javascript maybe some javascript developer can help me out…
Thanks again.

Rather than going through your code myself to find the problem in JS, if you could explain here then we can try to help you with JS problems too :slight_smile: