what the bleep is going on here

ok, i’m having a rough time trying to figure this out. i’m trying to figure out 2 things with this current script

1 - why the default submission can’t be cancelled out and
2 - why I can’t get the data to show up in the console

this is what I have for a script so far

[code][/code]
I’ve been following a video tutorial from http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-day-13/, using firefox since I already had firebug installed.

When I run the page, the script is already running, which it shouldn’t be (unless I messed something up). No matter what I do, its defaulting to the page in the form action. I thought return false; got rid of that, but it doesn’t seem to.

this is the form

[code]<form id=“subticket” method=“post” action=“inc/ajax_process_ticket.php”?>






<?=strip_slashes_recursive($read)?>

[/code]

The page is being loaded from index.php with

<script type="text/javascript"> $("#viewtickets").load('inc/ajax_load_tickets.php'); </script>
Maybe that has something to do with it? The script above is being run from ajax_load_tickets.php, not the index page.

I’m not sure if this is the issue, I’m just taking a quick glance before I go to work.

[php]<form id=“subticket” method=“post” action=“inc/ajax_process_ticket.php”?>[/php]

What’s the question mark for at the end of the form tag for? It looks like a typeo.

I caught that earlier, didn’t fix anything. I just can’t get it to stop using the form action. One other thing I noticed, its using get instead of post.

All I was trying to do was verify that the data is getting to the script. I made it into a regular function and had some success using alerts instead of console, but it went down shortly after that and its still not working as it should. I changed how the page is being loaded from the jquery load to a php include. Probably not the best way of doing it, but we never have more than maybe 10 tickets open at any given time.

I’ve seen some ways where they use the form name to create the click even, but that hasn’t worked for me either.

Is it possible to post the entire “ajax_load_tickets.php” page? Just not sections of it.

its a php script that runs a query for open tickets. I put it below
[php]<?php
//require ‘config.php’;
require_once ‘functions.php’;

//for testing purposes only
$_SESSION[‘adminname’] = ‘Richard’;

//Set the statuses to an array, cleans the code up at the bottom.
$statuses[0] = “Closed”;
$statuses[1] = “On Hold”;
$statuses[2] = “New”;
$statuses[3] = “A.C.R”;
$statuses[4] = “Updated”;

if(isset($_POST[‘close’])) {
for($i = 0; $i < count($_POST[‘ck’]); $i++) {
//echo $_POST[‘ck’][$i]."
";
$rid = $_POST[‘ck’][$i];
mysql_query(“UPDATE venzo_contactus SET status = 0 WHERE req_id = ‘$rid’”) or die(mysql_error());
}
}

$query = mysql_query(“SELECT * FROM venzo_contactus WHERE status <> 0 ORDER BY date DESC”) or die(mysql_error());
if(!mysql_num_rows($query)) { //if there is no data returned from the query

echo "<center>No Inquires to display.</center>";

} else { //If there is data returned
//Display the Table header
?>











<?php $date = date("Y-m-d"); $CurDate = strtotime($date); $yesterday = strtotime("-1 day", $CurDate); $i = 0; //We'll use this to create dynamic ID's so the Javascript knows what row to "Drop down" while($r = mysql_fetch_assoc($query)) { //Loop through the data array, assign it to $r $status = $statuses[$r['status']]; $compare = strtotime($r['date']); if($compare > $yesterday) { $new = "$r[req_id]"; } else { $new = $r['req_id']; } if(trim($r['subject']) == "") //If your checking for an empty variable, always trim() it to clear any whitespaces { $r['subject'] = "Test"; } if(trim($r['last_answered_by']) == "") { $ans = "Open"; } else { $ans = $r['last_answered_by']; } if($i % 2) { echo "\n"; } else { echo "\n"; } if(empty($r['last_answered_by'])) //empty($var) is the same as $var == "" { $ans = ""; } else { $val = explode(', ', $r['last_answered_by']); $ans = end($val); } ?>
    <td style="width: 25px; padding-right: 10px;"><?php echo $new; ?></td>
    <td style="width: 100px; padding-right: 10px;"><?=date('m/d/Y', strtotime($r['createdon']))?></td>
    <td style="width: 30px; padding-right: 10px;"><?php echo $status; ?></td>
    <td style="width: 200px; padding-right: 10px;"><?php echo $r['email']; ?></td>
    <td><?php echo truncate(stripslashes($r['subject'])); ?></td>
    <td style="width: 200px;"><?=date('m/d/Y', strtotime($r['date']))?> @ <?=date('h:i:s a', strtotime($r['date']))?></td>
    <td style="width: 120px;" nowrap="nowrap"><?php echo $ans; ?></td>
    <td style="width: 25px; padding-right: 10px;">
       <a href="#<?=$i?>" onclick="ShowEdit('<?=$i?>')"> <img src="images/icn_edit.png" title="Edit News" alt="Edit News" border="0" /></a>
    <input type="image" src="images/icn_trash.png" title="Trash">
    </td>
    </tr>
    <!-- this is your drop down row put what you want in here -->
    <tr style="display:none;" id="<?=$i?>" >
   		<td colspan="8">
			<a name="<?=$i?>"></a>
			<table cellpadding="1" cellspacing="1" border="0" width="100%" id="inq_tab">
				<tr>
					<td colspan="3" height="100" valign="top">
						<div style="height: 100px; overflow: auto; padding-top: 5px; padding-left: 5px;background-color:#EEEEEE; border:1px solid #dddddd;">
							<?=nl2br(strip_slashes_recursive($r['message']))?>
						</div>
					</td>
				</tr>
			</table>
			<br />
			<div style="width: 99.5%;">
				<form action="" method="post" name="myform">
					<div style="float: left; width: 90px; margin: 0 auto;">
						<input type="submit" name="close" value="close message" />
					</div>
					<div style="float: right;">
						<select name="danswer" id="danswer" >
						<?php
							$ans = mysql_query("SELECT * FROM venzo_contactus_answers") or die(mysql_error());
							while($row = mysql_fetch_array($ans)) {
								echo "<option value='$row[id]'>$row[name]</option>";
							}
							unset($row);
						?>
						</select>
						<input type="button" id="a_select" name="select" value="Select" onclick="ajaxFunction();"/>
						<input type="hidden" name="id" value="<?=$id?>" />
						<input type="hidden" name="req_id" value="<?=$r['req_id']?>" />
					</div>
				</form>
			</div>
			<div style="clear: both;"> </div>
			<form id="subticket" method="POST" action="inc/ajax_process_ticket.php" >
				<input type="hidden" id="tid" name="tid" value="<?=$r['id']?>" />
				<input type="hidden" id="replyto" name="cemail" value="<?=$r['email']?>" />
				<input type="hidden" id="req_id" name="req_id" value="<?=$r['req_id']?>" />
				<input type="hidden" id="u_name" name="u_name" value="<?=$r['name']?>" />
				<input type="hidden" id="a_name" name="a_name" value="<?=$_SESSION['adminname']?>" />
				<input type="hidden" id="div_id" value="<?=$i?>" />
				<textarea style="width: 99%;" rows="11" name="n_answer" id="reply"><?=strip_slashes_recursive($read)?></textarea>
				<div align="center" style="width: 100%;"><input type="button" onclick="processTicket()" id="igjo" name="igjo" value="Answer" /></div>
			</form>
		</td>
    </tr>
    <!-- end drop down row -->
    <?php
	$i++;
}

}
?>

Req ID Submitted Status From Topic Updated On Ans’d by
[/php]

Where is that jquery script, I don’t see it in the code you posted, also I see it’s calling processtickets, which I also don’t see the code for.

Is everything in the functions.php?

processTicket() is this renamed:

[code]script type=“text/javascript”>
$(document).ready(function() {
$(function() {
$("#igjo").click(function() {

			var tid = $("#tid").val();
			var replyto = $("#replyto").val();
			var reqid = $("#req_id").val();
			var uname = $("#u_name").val();
			var aname = $("#a_name").val();
			var divid = $("#div_id").val();
			var reply = $("#reply").val();
			
			alert(tid);
			
			return false;
		});
	});
});

[/code]

When you run the following code below, what happens, just like it is, don’t restructure it.

[php]<?php
//require ‘config.php’;
require_once ‘functions.php’;
?>

<?php //for testing purposes only $_SESSION['adminname'] = 'Richard'; //Set the statuses to an array, cleans the code up at the bottom. $statuses[0] = "Closed"; $statuses[1] = "On Hold"; $statuses[2] = "New"; $statuses[3] = "A.C.R"; $statuses[4] = "Updated"; if(isset($_POST['close'])) { for($i = 0; $i < count($_POST['ck']); $i++) { //echo $_POST['ck'][$i]."
"; $rid = $_POST['ck'][$i]; mysql_query("UPDATE venzo_contactus SET status = 0 WHERE req_id = '$rid'") or die(mysql_error()); } } $query = mysql_query("SELECT * FROM venzo_contactus WHERE status <> 0 ORDER BY date DESC") or die(mysql_error()); if(!mysql_num_rows($query)) { //if there is no data returned from the query echo "No Inquires to display."; } else { //If there is data returned //Display the Table header ?>
<table cellpadding="2" cellspacing="1" border="0" style="width: 99%; padding-left: 5px; font-size: 12px;">
    <tr>
        <td width="32" style="text-align: center;">Req ID</td>
        <td width="107" style="text-align: center;">Submitted</td>
        <td width="37" style="text-align: center;">Status</td>
        <td width="207" style="text-align: center;">From</td>
        <td width="415" style="text-align: center;">Topic</td>
        <td width="229" style="text-align: center;">Updated On</td>
        <td width="121" style="text-align: center;">Ans'd by</td>
        <td width="104" style="text-align: center;"></td>
    </tr>
<?php $date = date("Y-m-d"); $CurDate = strtotime($date); $yesterday = strtotime("-1 day", $CurDate); $i = 0; //We'll use this to create dynamic ID's so the Javascript knows what row to "Drop down" while($r = mysql_fetch_assoc($query)) { //Loop through the data array, assign it to $r $status = $statuses[$r['status']]; $compare = strtotime($r['date']); if($compare > $yesterday) { $new = "$r[req_id]"; } else { $new = $r['req_id']; } if(trim($r['subject']) == "") //If your checking for an empty variable, always trim() it to clear any whitespaces { $r['subject'] = "Test"; } if(trim($r['last_answered_by']) == "") { $ans = "Open"; } else { $ans = $r['last_answered_by']; } if($i % 2) { echo "\n"; } else { echo "\n"; } if(empty($r['last_answered_by'])) //empty($var) is the same as $var == "" { $ans = ""; } else { $val = explode(', ', $r['last_answered_by']); $ans = end($val); } ?>
    <td style="width: 25px; padding-right: 10px;"><?php echo $new; ?></td>
    <td style="width: 100px; padding-right: 10px;"><?=date('m/d/Y', strtotime($r['createdon']))?></td>
    <td style="width: 30px; padding-right: 10px;"><?php echo $status; ?></td>
    <td style="width: 200px; padding-right: 10px;"><?php echo $r['email']; ?></td>
    <td><?php echo truncate(stripslashes($r['subject'])); ?></td>
    <td style="width: 200px;"><?=date('m/d/Y', strtotime($r['date']))?> @ <?=date('h:i:s a', strtotime($r['date']))?></td>
    <td style="width: 120px;" nowrap="nowrap"><?php echo $ans; ?></td>
    <td style="width: 25px; padding-right: 10px;">
       <a href="#<?=$i?>" onclick="ShowEdit('<?=$i?>')"> <img src="images/icn_edit.png" title="Edit News" alt="Edit News" border="0" /></a>
    <input type="image" src="images/icn_trash.png" title="Trash">
    </td>
    </tr>
    <!-- this is your drop down row put what you want in here -->
    <tr style="display:none;" id="<?=$i?>" >
   		<td colspan="8">
			<a name="<?=$i?>"></a>
			<table cellpadding="1" cellspacing="1" border="0" width="100%" id="inq_tab">
				<tr>
					<td colspan="3" height="100" valign="top">
						<div style="height: 100px; overflow: auto; padding-top: 5px; padding-left: 5px;background-color:#EEEEEE; border:1px solid #dddddd;">
							<?=nl2br(strip_slashes_recursive($r['message']))?>
						</div>
					</td>
				</tr>
			</table>
			<br />
			<div style="width: 99.5%;">
				<form action="" method="post" name="myform">
					<div style="float: left; width: 90px; margin: 0 auto;">
						<input type="submit" name="close" value="close message" />
					</div>
					<div style="float: right;">
						<select name="danswer" id="danswer" >
						<?php
							$ans = mysql_query("SELECT * FROM venzo_contactus_answers") or die(mysql_error());
							while($row = mysql_fetch_array($ans)) {
								echo "<option value='$row[id]'>$row[name]</option>";
							}
							unset($row);
						?>
						</select>
						<input type="button" id="a_select" name="select" value="Select" onclick="ajaxFunction();"/>
						<input type="hidden" name="id" value="<?=$id?>" />
						<input type="hidden" name="req_id" value="<?=$r['req_id']?>" />
					</div>
				</form>
			</div>
			<div style="clear: both;"> </div>
			<form id="subticket" method="POST" action="inc/ajax_process_ticket.php" >
				<input type="hidden" id="tid" name="tid" value="<?=$r['id']?>" />
				<input type="hidden" id="replyto" name="cemail" value="<?=$r['email']?>" />
				<input type="hidden" id="req_id" name="req_id" value="<?=$r['req_id']?>" />
				<input type="hidden" id="u_name" name="u_name" value="<?=$r['name']?>" />
				<input type="hidden" id="a_name" name="a_name" value="<?=$_SESSION['adminname']?>" />
				<input type="hidden" id="div_id" value="<?=$i?>" />
				<textarea style="width: 99%;" rows="11" name="n_answer" id="reply"><?=strip_slashes_recursive($read)?></textarea>
				<div align="center" style="width: 100%;"><input type="button" id="igjo" name="igjo" value="Answer" /></div>
			</form>
		</td>
    </tr>
    <!-- end drop down row -->
    <?php
	$i++;
}

}
?>

[/php]

When i ran it like that, it brought up the alert box like it was supposed to. But once i added in the $.ajax call, it just tells me that it can’t find the function. Not sure if that has something to do with the function being on the index page instead of on ajax_load_tickets though. When the index page loads, div’s that are supposed to be closed are appearing open too.

I’ll pm you the url so you can see what its doing.

Sponsor our Newsletter | Privacy Policy | Terms of Service