Jump to content

code not showing correct result


narjis

Recommended Posts

I am posting two valuies via text box and textarea but these values are not being posted to my php script please chechk my code where I'm going wrong. In my database blanck values are being inserted.

// JavaScript Document
$(document).ready(function(){
$("#response").hide();
$("input.addbtn").click(function(){
	var name = $("#name").val();
	var comment = $("#comment").val();
	//var datastring ="name="+name+"&comment="+comment;
	$.post(
	'process.php',
	(
	name,
	comment
	),
	function(response){
		$("#response").fadeIn("fast");
		$("#response").html("Comment Added").css("padding","10px");
		$("#name").val("");
		$("#comment").val("");
		$("#wrapper").hide();
		}
	)
	return false;

	});
});

Here is my html code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page1</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>

<body>
<div id="wrapper">
<table align="center">
<form method="post" action="" class="commentForm">
<tr>
<td colspan="2"><th colspan="2">Add your Comments</th> </td>
</tr>
<tr>
<td colspan="2"><label for="name" >Name :</label></td><td width="161"><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td colspan="2"><label for="comment" >Comment :</label></td>
    <td><textarea name="comment"cols="20" rows="5" id="comment"></textarea> </td>
</tr>
<tr>
<td>
    <input  align="center" class="addbtn" type="submit" name="submit" value="Add"  /></td>
</tr>
</form>
</table>
</div>
<div id="response"></div>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/253080-code-not-showing-correct-result/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.