Thứ Sáu, 16 tháng 9, 2011

Javascript post on form Submit open a new window


1/ html form

form name="my_form"
Title: input type="text" name="txttitle"
Content: textarea name="txtcontent" textarea
input type="submit" name="btsubmit" value="Submit"
input type="button" name="btreview" value="Review"

2/ jquery or javascript function 

//jquery
$('#btreview').click(function(){
with(document.my_form) {
method = 'POST';
action = 'php_post.php';
target = '_blank';
submit();
}
});
//javascript funtion
function review()
{
with(document.my_form) {
method = ‘POST’;
action = ‘php_post.php’;
target = ‘_blank’;
submit();
}
}
Nếu sử dụng javascript funtion nhớ khai báo gọi hàm tại tab button

input type="button" name="btreview" value="Review" onclick="/review();/"
do blog không cho post thẻ(tag) html nên các bạn nhớ ghi thẻ cho đúng <inp…, , ..etc

Không có nhận xét nào: