Forum Moderators: coopster

Message Too Old, No Replies

Undefined index

         

khaki monster

11:09 am on Feb 9, 2007 (gmt 0)

10+ Year Member



i dont know what would i name for this thread of mind. basically i having throuble working on with my JavaScript bellow:


function goDelete(){
var recslen = document.forms[0].length;
var checkboxes = "";
for(i = 1; i < recslen; i++){
if(document.forms[0].elements[i].checked==true)
checkboxes += " " + document.forms[0].elements[i].name
}
if(checkboxes.length>0){
var con=confirm("Are you sure you want to delete");
if(con){
document.forms[0].action="delete.php?rec_id="+checkboxes
document.forms[0].submit()
}
}else{
alert("No record is selected.")
}
}

function selectAll(){
var recslen = document.forms[0].length;
if(document.forms[0].checkAll.checked==true){
for(i=1;i<recslen;i++) {
document.forms[0].elements[i].checked=true;
}
}else{
for(i=1;i<recslen;i++)
document.forms[0].elements[i].checked=false;
}
}

after the execution script.js, it will then process delete.php with the code bellow:


<?php
require("config.php");
include("modlib.php");
conn_db($host, $user, $pass, 'superdb');

$rec = $_GET['rec_id'];

$data = trim($rec);
$delimiter = explode(" ",$data);
$size= count($delimiter);

for($i=0; $i<$size; $i++) {
$del_id=trim($delimiter[$i]);

$seek = 'SELECT news_mas.lock FROM news_mas WHERE news_mas.mas_id = '.$del_id;
$que = mysql_query($seek) or die('Problem:'.mysql_error());

while ($pos = mysql_fetch_array($que)){
if (is_null($pos['lock']) ¦¦ $pos['lock'] == 0){
$query = 'DELETE FROM news_mas, news_dtl WHERE news_mas.mas_id = '.$del_id.' AND news_dtl.dtl_id = '.$del_id;
$result = mysql_query($query) or die('Problem: '.mysql_error());
}
}
}
header('location: '.$_SERVER['HTTP_REFERER']);
?>

now my problem why my JS cannot able to pas variables to delete.php?
this code below is the main program:


<?php
require("config.php");
include("modlib.php");
conn_db($host, $user, $pass, 'superdb');
$location = $section = NULL;

if (isset($_GET["mnuLocation"]) && is_numeric($_GET["mnuLocation"])){
// Change the location var from NULL to mnuLocation
$location = $_GET["mnuLocation"];
}

if (isset($_GET["mnuSection"]) && is_numeric($_GET["mnuSection"])){
// Change the section var from NULL to mnuSection
$section = $_GET["mnuSection"];
}
?>

<html>
<head>
<link href="../balita.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="script.js"><!-- //--></script>
<style type="text/css">
<!--
body {
background: #CCCC99;
margin: 0px;
}
-->
</style>
</head>
<body>
<form name="frmQue" method="get">
<table width="450" border="0" cellpadding="0" cellspacing="0" style="border-bottom: solid 4px #999966;">
<tr bgcolor="#CCCCFF">
<td height="24" colspan="3" bgcolor=""><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-bottom: solid 4px #999966;">
<tr>
<td width="38" height="20" class="capIt">Filter</td>
<td width="100"><select name="mnuLocation" id="mnuLocation" class="selval2">
<option value="null"></option>
<option value="1" <?php if($location == 1) echo " selected";?>>Cag. de Oro</option>
<option value="2" <?php if($location == 2) echo " selected";?>>Cebu</option>
<option value="3" <?php if($location == 3) echo " selected";?>>Davao</option>
<option value="4" <?php if($location == 4) echo " selected";?>>Gen. Santos</option>
</select></td>
<td width="95"><select name="mnuSection" id="mnuSection" class="selval2">
<option value="null"></option>
<option value="1" <?php if($section == 1) echo " selected";?>>Balita</option>
<option value="2" <?php if($section == 2) echo " selected";?>>Opinyon</option>
<option value="3" <?php if($section == 3) echo " selected";?>>Kalingawan</option>
<option value="4" <?php if($section == 4) echo " selected";?>>Sports</option>
</select></td>
<td width="43" class="capIt">Search</td>
<td width="89"><input name="cmdSearch" type="image" src="rel_script/action_go.gif" width="16" height="16" border="0" style="margin-top: 3px;"></td>
<td width="23" align="center"><input name="checkAll" type="checkbox" id="checkAll" onClick="selectAll();" value="ON"></td>
<td width="62" align="center" class="capIt"><a href="javascript:goDelete()">DELETE</a></td>
</tr>
</table></td>
</tr>
<?php
if(!is_null($location) && is_numeric($location) &&!is_null($section) && is_numeric($section)){
$query = 'SELECT news_mas.mas_id, news_mas.location, news_mas.section, news_mas.lock, news_dtl.date, news_dtl.title FROM news_mas, news_dtl
WHERE news_mas.mas_id = news_dtl.dtl_id AND news_mas.location = '.$location.' AND news_mas.section = '.$section.' ORDER BY news_dtl.date';
$result = mysql_query($query) or die('Error: '.mysql_error());
if(!mysql_num_rows($result) > 0){
echo '<script type="text/javascript">alert("No Articles Found!..")</script>';
exit;
}
session_start();
while($ctr = mysql_fetch_array($result)){ //Begin While
$section = $ctr['section'];
$location = $ctr['location'];
switch($section){ // Begin Switch
case 1: $sec = 'Balita'; break;
case 2: $sec = 'Opinyon'; break;
case 3: $sec = 'Kalingawan'; break;
case 4: $sec = 'Sports'; break;
} // End Switch
switch($location){ // Begin Switch
case 1: $loc = 'CDO'; break;
case 2: $loc = 'CBU'; break;
case 3: $loc = 'DVO'; break;
case 4: $loc = 'GEN'; break;
} // End Switch
$_SESSION['article_id'] = $ctr['mas_id'];
if(is_null($ctr['lock']) ¦¦ $ctr['lock'] == 0){ //?>
<tr>
<td width="373" height="20" class="trbdr"><?php echo $loc.' - '.$sec.': ';?><a href="rel_script/view_article.php?article_id=<?= $ctr['mas_id'];?>" target="_blank">
<?= filval(charslen(48, $ctr['title']));?>
</a> </td>
<td width="35" class="trbdr"><a href="mod_update.php?article_id=<?= $ctr['mas_id'];?>">Edit</a></td>
<td width="42" class="trbdr"><input name="<? echo $ctr['mas_id'];?>" type="checkbox" class="check">
</td>
</tr>
<?php }elseif($ctr['lock'] == 1){?>
<tr>
<td height="20" class="trbdr"><?php echo $loc.' - '.$sec.': '.filval(charslen(48, $ctr['title']));?> </a> </td>
<td width="35" class="trbdr">Edit</td>
<td width="42" class="trbdr"><input name="" type="checkbox" disabled="disabled"></td>
</tr>
<?php }
} // end while
free_mem($result);
}
?>
</table>
</form>
</body>
</html>

please im disperate...

tanx to any help

eelixduppy

11:54 am on Feb 9, 2007 (gmt 0)



You have labeled this thread
Undefined index
. If you are receiving this error, then please give the corresponding line number as this will help with debugging. Any other errors, and yes that included javascript ones :), should also be given. Thanks.