實(shí)現(xiàn)將表單中的數(shù)據(jù)提交到商務(wù)通后臺(tái)的效果,中文說(shuō)明并且實(shí)現(xiàn)換行顯示。
代碼簡(jiǎn)單容易理解,這里就不多解釋了。
要點(diǎn):1、使用escape函數(shù)對(duì)中文進(jìn)行編碼;2、使用br標(biāo)簽進(jìn)行換行。
效果如下圖:
前臺(tái)界面
提交到商務(wù)通后臺(tái)的結(jié)果
提交到商務(wù)通后臺(tái)的結(jié)果
具體代碼如下:
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>表單提交到商務(wù)通后臺(tái) 中文說(shuō)明加換行的實(shí)現(xiàn)方法</title>
<style type="text/css">
#yuyue {width:320px;margin:0 auto;}
</style>
</head>
<body>
<div id="yuyue">
<p>姓名: <input type="text" id="gname"></p>
<p>年齡: <input type="text" id="gage"></p>
<p>電話: <input type="text" id="gphone"></p>
<p>留言: <textarea id="gmsg" cols="30" rows="4"></textarea></p>
<p><input type="button" value="提交" onclick="submit_to_swt();"></p>
</div>
<script type="text/javascript">
function submit_to_swt(){
var name = document.getElementById("gname");
var age = document.getElementById("gage");
var phone = document.getElementById("gphone");
var msg = document.getElementById("gmsg");
if(name.value==""){
alert("請(qǐng)輸入您的姓名!");
name.focus();
return false;
}
if(age.value==""){
alert("請(qǐng)輸入您的年齡:!");
age.focus();
return false;
}
if(phone.value==""){
alert("請(qǐng)輸入您的電話!");
phone.focus();
return false;
}
if(msg.value==""){
alert("請(qǐng)輸入您的留言:!");
msg.focus();
return false;
}
if(typeof openZoosUrl != "undefined"){
openZoosUrl('chatwin','&e='+escape('姓名:'+name.value+'<br/>年齡:'+age.value+'<br/>電話:'+phone.value+'<br/>留言:'+msg.value));
}
}
</script>
<!--測(cè)試請(qǐng)將此處商務(wù)通代碼替換為你的-->
<script language="javascript" src="http://dat.zoosnet.net/LR/Chatpre.aspx?id=DAT1111111&float=0&lng=cn"></script>
<!--測(cè)試請(qǐng)將此處商務(wù)通代碼替換為你的-->
</body>
</html>