新闻中心

Dedecms如何用自定义表单用js代替联动类型

作者 / 无忧主机 时间 2014-08-15 17:46:47

无忧主机小编发现DEDECMS内置的联动类型被注释掉了,网上虽然有解决联动类型的例子,但大多都存在后台信息的是枚举,都是一些数字,于是无忧主机小编自己便采取了比较取巧的方案,用js代替联动类型。 无忧小编用DEDECMS完成一个自定义表单,要用到地区的三级级联,地区肯定要使用option下拉框,如果让人一个个填那是肯定不行的,自定义表单的字段的类型都使用单行文本,设置完之后前台查看,并浏览器查看它的源文件。 例如:   <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> 以上就是无忧主机小编分享的用js代替联动类型的方法,希望对大家有所帮助。   无忧主机相关文章推荐阅读: 如何加快DEDECMS内容生成速度方法 加快DEDEMCS全站新文章快速收录的方法 DEDECMS网站迁移时出现数据库导入失败的解决方案之一 DEDECMS教程:实现有短标题时显示短标题、无短标题时显示长标题

本文地址:https://www.51php.com/dedecms/15864.html

1
1
1
1
1
1
1

客户服务热线

0791-8623-3537

在线客服