为了提高体验度,今天上午特意下载织梦cms 浏览了一下, 网上也看到相关文档, 但是实践中还是有问题, 自己重新写了一笔, 下面是代码和截图
- 第一步上图表单部分
<div class="cbox mceneter">
<div class="maplist">
<br />
<!--------->
<div class="cmain">
<div class="ctitle">
<h1>预约表单发布</h1>
<span></span>
</div>
<div class="cbox mceneter">
<div class="maplist">
<br />
<form action="/plus/diy.php" enctype="multipart/form-data" method="post">
<table style="width:97%;" cellpadding="0" cellspacing="1">
<tr>
<td align="right" valign="top">姓名:</td>
<td><input type='text' name='name' id='name' style='width:250px' class='intxt' value='' />
</td>
</tr>
<tr>
<td align="right" valign="top">性别:</td>
<td><input type='text' name='sex' id='sex' style='width:250px' class='intxt' value='' />
</td>
</tr>
<tr>
<td align="right" valign="top">电话:</td>
<td><input type='text' name='phone' id='phone' style='width:100px' class='intxt' value='' /> (填写数值)
</td>
</tr>
<tr>
<td align="right" valign="top">科室:</td>
<td><input type='text' name='kehsi' id='keshi' style='width:250px' class='intxt' value='' />
</td>
</tr>
</table>
<div align='center' style='height:30px;padding-top:10px;'>
<input type="button" name="submit" value="提 交" class='coolbg' οnclick="add_info()" />
<input type="reset" name="reset" value="重 置" class='coolbg' />
</div>
</form>
</div>
</div>
</div>
</div>
<script src="http://www.86900000.com/statics/js/js/jquery-1.8.0.min.js"></script>
<script>
function add_info(){
var name = document.getElementById("name").value; //第一种简化方法 var name = document.getElementById("name").value;
var sex = document.getElementById("sex"); //第二种简化方法还可以这样 var sex=$("#sex").val();
var phone = document.getElementById("phone"); // // 第三种 $("input[name='items']:checked").val();
var keshi = document.getElementById("keshi");
//参数设置
var dataString = 'name='+name+'&sex='+sex.value+'&phone='+phone.value+'&keshi='+keshi.value+
'&action=post'+ '&diyid=1&do=2&dede_fields=name,text;sex,text;phone,int;kehsi,text&dede_fieldshash=5d90a23de0871ae2678999f6ed349865';
$.ajax({
type: "POST",
url: "/plus/diy.php",//提交到后台文件
data: dataString,//传值
success: function(data) {
alert("手机提交成功,稍后客服人员将与您联系!");
}
});
}
</script>
仅供学习使用
代码贡献人:seridy