I am new to Javascript and I don't want to use frameworks. I found a tutorial on how to make this:
<html>
<head>
<title></title>
<script src="jquery-1.4.2.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("div#msgbox").hide();
$("#addComment").click(function (){
$.post('index1.php', {
name:$("#name").val(), //PHP recognize it like POST
comment:$("#comment").val() //PHP recognize it like POST
},
function(response){
$("div#msgbox #msg").html("<h2>Comment added!</h2>");
$("div#msgbox").hide().slideDown("normal"); //slideDown or shoe
}
);
return false;
})
$("div#msgbox").click(function() {
$(this).slideUp("normal"); //slideUp or hide
}
)
});
</script>
<style type="text/css">
body{
margin:0px;
}
#msgbox{
height:50px;
width:100%;
background:#999;
position:fixed;
}
</style>
</head>
<body>
<div id="msgbox">
<span id="msg">
</span>
</div>
<form id="commentForm">
Name: <input type="text" id="name" />
Comment: <input type="text" id="comment" />
<input type="submit" id="addComment" value="Post Comment" />
</form>
It takes name and comment value and sends it as $_POST and $_POST to post.php. I was wondering can somebody write this in raw javascript.