-1

I am facing a proble while sending multiple data in javascript..Let me demonstrate my code..

<td><input type="button" onclick="deletecom(<?php echo 
 $id,$employee>)"name="delete" value="Delete"></td>
 </tr>
 <script language="javascript">
 function deletecom(delcom,delcom1)
 {
     if(confirm("are u sure"))
     {
         window.location.href='delete_commision.php?del_com='+delcom+ 
'&del_com1='+delcom1+;


        return true;

     }
 }


 </script>

Here is my delete_commision.php code

<html>
<body>
<?php
include("index.php");
include("includes/connect.php");
$del_com=$_GET['del_com'];
$del_com1=$_GET['del_com1'];

echo $del_com,$hello;
echo $del_com1;

?>

</body>
</html>

The problem is that when I used to click or send the arguments it not showing the values of second variable..

here is the output..

Notice: Undefined index: del_com1 in C:\xampp\htdocs\Neisha\delete_commision.php on line 7

21

Here the 21 is the value that I am passing i.e ID

The 1st variable is showing the correct value but I am not understanding the second one's problem

Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
Indranil
  • 53
  • 4

3 Answers3

0

Change your onclick value with this onclick="deletecom( <?php echo $id ?>, <?php echo $employee ?>)"

Haze
  • 195
  • 7
0

This will help you

<tr>
    <td>
        <input type="button" onclick="deletecom(<?php echo $id.",".$employee ?>)" name="delete" value="Delete">
    </td>
</tr>
<script language="javascript">
    function deletecom(delcom,delcom1)
    {
        if(confirm("Are you sure you want to delete??"))
        {
            window.location.href='delete_commision.php?del_com='+delcom+'&del_com1='+delcom1;
            return true;
        }
    }
</script>

Happy Coding :-)

Yash Parekh
  • 1,513
  • 2
  • 20
  • 31
  • Parse error: syntax error, unexpected '.' in C:\xampp\htdocs\Neisha\view_commision.php on line 129 – Indranil Oct 31 '17 at 07:25
  • Change that line to :- `)" name="delete" value="Delete">` I've already mentioned that thing in my answer above... – Yash Parekh Oct 31 '17 at 12:54
  • I already tried ur suggestion like u said but now its showing the confirmation box and when I used to click on "YES" then the page is not reditecting to the "delete_commision.php" page. – Indranil Nov 01 '17 at 07:01
  • Check your console for errors and If its all okay then copy the delete link and paste it in browser with values. I think this happens because of path mismatch. – Yash Parekh Nov 02 '17 at 07:12
  • How to check for errors ..?..Actually I am beginner in php so I dont have idea on that...I checked in google also but I didn't get that.. – Indranil Nov 03 '17 at 07:32
  • For javascript error check your console logs (by pressing F12 key on your browser page) and for php error use `try...catch` block... – Yash Parekh Nov 03 '17 at 10:57
-2

Yes oF Course you can pass multiple arguments using java scripts

here go through this example so you can have an idea on it

var sum = function () {
    var res = 0;
    for (var i = 0; i < arguments.length; i++) {
        res += parseInt(arguments[i]);
    }
    return res;
 }
Urstruely Ananth
  • 73
  • 2
  • 2
  • 9