1. ส่วนหนึ่งของรหัส JS
คัดลอกรหัสรหัสดังนี้:
-
* ส่งแบบฟอร์ม
-
ฟังก์ชั่น submentForm (การกระทำ, actname, objname, formName, blogType) {
$ ("#"+formName) .attr ("การกระทำ", การกระทำ);
// var f = document.getElementsByTagname ("ฟอร์ม") [0];
// Alert (f.action);
$ ("#"+FormName) .Form ({
onsubmit: function () {
checkInput ();
-
ความสำเร็จ: ฟังก์ชั่น (ข้อมูล) {
if (data == "ความสำเร็จ") {{
$ .messager.alert ('พรอมต์', '<br> บันทึกสำเร็จ!', 'ข้อมูล');
} อื่น {
$ .messager.alert ('เคล็ดลับ', '<br> บันทึกล้มเหลว!', 'คำเตือน');
-
-
-
-
-
* เผยแพร่บันทึก
-
fublishblog () {
SubmitForm ("http: // localhost: 8090/webplus3/_web/sns/createblog.do?
-
2. ส่วน HTML
คัดลอกรหัสรหัสดังนี้:
<form style = "padding: 10px 8px;" method = "post" action = "id =" fm1 "name =" fm1 ">
<div style = "margin-bottom: 10px;">
<span style = "padding-right: 10px;"> title: </span>
<input type = "text" id = "title" name = "blog.tital" maxlength = "30">
</div>
<div style = "margin-bottom: 10px;">
<span style = "padding-right: 10px;"> เนื้อหา: </span>
<input type = "text" id = "content" name = "blog.content" maxLength = "3000">
</div>
<button type = "ส่ง" id = "saveblogbutton" onclick = "publicishblog ()">
<span> โพสต์ </span>
</kout>
</form>