dedecms自定義表單用js代替聯動類型解決聯動問題
來源:易賢網 閱讀:733 次 日期:2014-09-24 10:46:17
溫馨提示:易賢網小編為您整理了“dedecms自定義表單用js代替聯動類型解決聯動問題”,方便廣大網友查閱!

最近用DEDECMS完成一個自定義表單,要用到地區的三級級聯,地區肯定要使用option下拉框,如果讓人一個個填肯定不行,DEDECMS內置的聯動類型被注釋掉了,網上有解決聯動類型的例子,但存在后臺信息的是枚舉,都是數字,不方便查看,網上的解決方案都不怎么完全,嘗試了一下沒有成功,自己便采取了比較取巧的方案,用js代替聯動類型

自定義表單的字段的類型都使用單行文本,設置完之后前臺查看,并瀏覽器查看它的源文件。

例如:

代碼如下:

<form action="/plus/diy.php" enctype="multipart/form-data" method="post">

<input type="hidden" name="action" value="post" />

<input type="hidden" name="diyid" value="1" />

<input type="hidden" name="do" value="2" />

<table style="width:97%;" cellpadding="0" cellspacing="1">

<tr>

<td align="right" valign="top">省份:</td>

<td><input type='text' name='province' id='province' style='width:250px' class='intxt' value='' />

</td>

</tr>

<tr>

<td align="right" valign="top">地級市:</td>

<td><input type='text' name='city' id='city' style='width:250px' class='intxt' value='' />

</td>

</tr>

<tr>

<td align="right" valign="top">市、縣級市:</td>

<td><input type='text' name='country' id='country' style='width:250px' class='intxt' value='' />

</td>

</tr>

<input type="hidden" name="dede_fields" value="province,text;city,text;country,text" />

<input type="hidden" name="dede_fieldshash" value="652e45ca2c11e03bbe75d9f5ab1726ba" /></table>

<div align='center' style='height:30px;padding-top:10px;'>

<input type="submit" name="submit" value="提 交" class='coolbg' />

<input type="reset" name="reset" value="重 置" class='coolbg' />

</div>

</form>

修改它的form表單,改成自己所需要的樣式,并將province,city,country都改成select的類型,三級級聯使用js完成

如:

代碼如下:

<form action="/plus/diy.php" enctype="multipart/form-data" method="post">

<input type="hidden" name="action" value="post" />

<input type="hidden" name="diyid" value="1" />

<input type="hidden" name="do" value="2" />

<select id="s_province" name="province"><option value="省份">省份</option></select>

<select id="s_city" name="city" style="margin-left:20px;"><option value="地級市">地級市</option></select>

<select id="s_county" name="country" style="margin-left:20px;"><option value="市、縣級市">市、縣級市</option></select>

<script type="text/javascript" src="js/area.js"></script>

<script type="text/javascript">_init_area();</script>

<input type="hidden" name="dede_fields" value="province,text;city,text;country,text" />

<input type="hidden" name="dede_fieldshash" value="652e45ca2c11e03bbe75d9f5ab1726ba" /></table>

<div align='center' style='height:30px;padding-top:10px;'>

<input type="submit" name="submit" value="提 交" class='coolbg' />

<input type="reset" name="reset" value="重 置" class='coolbg' />

</div>

</form>

更多信息請查看IT技術專欄

更多信息請查看CMS教程
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
未满十八18勿进黄网站免费看