hi.i think i am asking a basic question, like i have submit button upon on click i am calling function which performs confirm() operation.. but now my problem is when i click on ok button i want my database opeartions should happen , if i press cancel it should not dont do any opeartions.. i think i need to use ajax for dis..as problem s with client side nd server side execution please any one can help me.. how can i achieve this..
my code is:
<input type=”submit” name=”Submit” onclick=”show_confirm()” value=”Add Menu Item” />
<script>
function show_confirm()
{
var r=confirm(“Do you want to add a menu item”);
if(r==true)
{
alert(“your menu has been added”);
}
if(r==false)
{
call ajax i think
}
}
my php code to be executed upon ok
<?php
ob_start();
include(“connection.php”);
$q1=”select * from menureg”;
$r1=mysql_query($q1);
$row1=mysql_num_rows($r1);
/
{
echo “you are not supposed to insert menu itm”;
}
*/
if(isset($_POST[‘Submit’]))
{
$name=$
$ord=$row1+1;
/*echo $q=”insert into menureg(menuname,order1)values(‘$name’,’$ord’)”;
echo $r=mysql_query($q);
$q1=”select * from menureg”;
$r1=mysql_query($q1);
$row1=mysql_num_rows($r1);
/
{
echo “you are not supposed to insert menu itm”;
}*/
if($row1<8)
{
$q=”insert into menureg(menuname,order1)values(‘$name’,’$ord’)”;
$r=mysql_query($q);
/*if($r)
{
header(“location:process.php”);
ob_flush();
}
}
else
{
$msg=”you are not supposed to insert menu item as limit is upto 8″;
}
}
?>