Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2011, 04:58 AM   PM User | #1
chaychie
New to the CF scene

 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
chaychie is an unknown quantity at this point
Unable to delete

Hi all!

I created a form where users are allowed to delete a specific row of data by clicking the "cancel" button from the drop down menu. However, I have a problem deleting my data using the javascript. Apparently, I only able to delete the first row of the data but not for the rest!

The following is the code i have:


PHP Code:
<html>
<body style="background-color:#E0FFFF;">


<script language="javascript" >
<!-- hide
function submitRequest(val) {
document.forms[0].submit();
}

// end hide -->
</script>

<?php

$con 
mysql_connect("localhost","root","");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("my_course"$con);

$result mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");
$result1 mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");

echo 
"<table border='1' cellpadding='2' cellspacing='0'>
<tr>
<th>CourseCode</th>
<th>CourseName</th>
<th>Year</th>
<th>Sem</th>
<th>Grade</th>
<th>Option</th>
</tr>"
;

?>

<?php

while($row mysql_fetch_array($result))
{
  echo 
"<tr>";
  echo 
"<td>" $row['CourseCode'] . "</td>";
  echo 
"<td>" $row['CourseName'] . "</td>";
  echo 
"<td>" $row['Year'] . "</td>";
  echo 
"<td>" $row['Sem'] . "</td>";
  echo 
"<td>" $row['Grade'] . "</td>";
  echo 
"<td>";

?>
<?php
?>

         <form name="form1" action="submitDelete.php" method="post">
       <select name="cancel" onchange="submitRequest(this.value);">
       <option value=> </option>
     <option value="<?php echo $row['CourseName'];?>">Cancel</option>
         </select>
         </form>

<?php
  
echo "</td>";
  echo 
"</tr>";
  }

echo 
"</table>";

mysql_close($con);
?>
    
<br/>
<br/>

</body>
</html>
Thanks in advance!
chaychie is offline   Reply With Quote
Old 07-05-2011, 10:35 AM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Apparently there is no javascript delete function within your code. It might be a php feature of this kind, but no javascript visible there, except a small code which simply submits the form's values to a php file.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 03:40 AM.


Advertisement
Log in to turn off these ads.