index.php
<html>
<head>
<script src="jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert('hai');
$(".sub").click(function(){
alert('hhh');
var pcheck="";
$(".pack").each(function(){
var id=$(this).attr("id");
if ($('#'+id).is(':checked'))
{
pcheck+=$('#'+id).val()+",";
}
});
alert(pcheck);
$.get("test.php",{Subject:pcheck,operation:"Sub"},function(data)
{
alert( "insert successfully");
});
});
});
</script>
</head>
<body>
<form method="post">
Subject:<br>
<input type="checkbox" class="pack" name="subject[]" value="English" id="1">English <br>
<input type="checkbox" class="pack" name="subject[]" value="Tamil" id="2">Tamil <br>
<input type="checkbox" class="pack" name="subject[]" value="Maths" id="3">Maths <br>
<input type="button" class="sub" name="sub" value="Submit">
</form>
</body>
</html>
______________________________________________________________________________
test.php
<?php
if(isset ($_GET['operation']) && $_GET['operation']!='')
{
include_once 'connect.php';
$op=$_GET['operation'];
if($op=='Sub')
{
$Subject=$_GET['Subject'];
$sql = mysql_query("insert into subject values('','$Subject')");
}
}
?>
______________________________________________________________________________
connect.php
<?php
$con=mysql_connect('localhost','root','');
mysql_select_db('dynamiccheck',$con);
?>
________________________________________________________________________________
No comments:
Post a Comment