Home > Web Front-end > HTML Tutorial > 用户注册提交如何进行前后端交互,我是新手做前端的不懂后端的,该如何改代码让它可以交互!急用_html/css_WEB-ITnose

用户注册提交如何进行前后端交互,我是新手做前端的不懂后端的,该如何改代码让它可以交互!急用_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:24:03
Original
1914 people have browsed it


    

非专利微信平台交流会签到


    【地点】:南京市
    2016年01月14日
    

    

        
        
    

    

输入不得为空。


    

        
        
    

    

输入不得为空。


        

        
        
    

    

输入不得为空。


    

        
        
    

输入不得为空。


    

        

    

<script> <br /> // 1. 获取省份列表,绑定onchange事件 <br /> var provinceElement = document.getElementById("province1"); <br /> provinceElement.onchange = function(){ <br /> // 清空城市列表 <br /> var cityElement = document.getElementById("city"); <br /> var opts = cityElement.getElementsByTagName("option"); <br /> for(var z=1;z<opts.length;z++){ <br /> cityElement.removeChild(opts[z]); <br /> z--; <br /> } <br /> var provinceValue = provinceElement.value; <br /> var cities; <br /> switch (provinceValue){ <br /> case "北京": <br /> cities = ['北京']; <br /> break; <br /> case "天津": <br /> cities = ['天津']; <br /> break; <br /> case "上海": <br /> cities = ['上海']; <br /> break; <br /> case "重庆": <br /> cities = ['重庆']; <br /> break; <br /> case "深圳": <br /> cities = ['深圳']; <br /> break; <br /> case "广东": <br /> cities = ['广州','珠海','中山','佛山','东莞','清远','肇庆','阳江','湛江','韶关','惠州','河源','汕尾','汕头','梅州']; <br /> break; <br /> case "河北": <br /> cities = ['石家庄','唐山','秦皇岛','邯郸','邢台','张家口','承德','廊坊','沧州','保定','衡水']; <br /> break; <br /> case "山西": <br /> cities = ['太原','大同','阳泉','朔州','长治','临汾','晋城']; <br /> break; <br /> case "内蒙古": <br /> cities = ['呼和浩特','包头','乌海','临河','东胜','集宁','锡林浩特','通辽','赤峰','海拉尔','乌兰浩特']; <br /> break; <br /> case "辽宁": <br /> cities = ['沈阳','大连','鞍山','锦州','丹东','盘锦','铁岭','抚顺','营口','辽阳','阜新','本溪','朝阳','葫芦岛']; <br /> break; <br /> case "吉林": <br /> cities = ['长春','吉林','四平','辽源','通化','白山','松原','白城','延边']; <br /> break; <br /> case "黑龙江": <br /> cities = ['哈尔滨','齐齐哈尔','牡丹江','佳木斯','大庆','伊春','黑河','鸡西','鹤岗','双鸭山','七台河','绥化','大兴安岭']; <br /> break; <br /> case "江苏": <br /> cities = ['南京','苏州','无锡','常州','镇江','连云港 ','扬州','徐州 ','南通','盐城','淮阴','泰州','宿迁']; <br /> break; <br /> case "浙江": <br /> cities = ['杭州','湖州','丽水','温州','绍兴','舟山','嘉兴','金华','台州','衢州','宁波']; <br /> break; <br /> case "安徽": <br /> cities = ['合肥 ','芜湖 ','蚌埠 ','滁州 ','安庆 ','六安 ','黄山 ','宣城 ','淮南 ','宿州 ','马鞍山 ','铜陵','淮北 ','阜阳 ','池州 ','巢湖 ','亳州']; <br /> break; <br /> case "福建": <br /> cities = ['福州 ','厦门 ','泉州 ','漳州 ','龙岩 ','南平 ','宁德 ','莆田 ','三明']; <br /> break; <br /> case "江西": <br /> cities = ['南昌','景德镇','九江','萍乡','新余','鹰潭','赣州','宜春','吉安','上饶','抚州']; <br /> break; <br /> case "山东": <br /> cities = ['济南','青岛','淄博','德州','烟台','潍坊','济宁','泰安','临沂','菏泽','威海','枣庄','日照','莱芜','聊城','滨州','东营']; <br /> break; <br /> case "河南": <br /> cities = ['郑州','开封','洛阳','平顶山','安阳','鹤壁','新乡','焦作','濮阳','许昌','漯河','三门峡','南阳','商丘','周口','驻马店','信阳','济源']; <br /> break; <br /> case "湖北": <br /> cities = ['武汉','黄石','十堰','荆州','宜昌','襄樊','鄂州','荆门','孝感','黄冈','咸宁','恩施','随州','仙桃','天门','潜江','神农架']; <br /> break; <br /> case "湖南": <br /> cities = ['长沙','株州','湘潭','衡阳','邵阳','岳阳','常德','郴州','益阳','永州','怀化','娄底','湘西 ']; <br /> break; <br /> case "广西": <br /> cities = ['南宁','柳州','桂林','梧州','北海','防城港','钦州','贵港','玉林','贺州','百色','河池']; <br /> break; <br /> case "海南": <br /> cities = ['海口 ','三亚','通什','琼海','琼山','文昌','万宁','东方','儋州']; <br /> break; <br /> case "四川": <br /> cities = ['成都','自贡','攀枝花','泸州','德阳','绵阳','广元','遂宁','内江','乐山','南充 ','宜宾','广安','达川','巴中','雅安','眉山 ','阿坝 ','甘孜 ','凉山 ']; <br /> break; <br /> case "贵州": <br /> cities = ['贵阳 ','六盘水','遵义','铜仁','毕节','安顺','黔西南 ','黔东南','黔南']; <br /> break; <br /> case "云南": <br /> cities = ['昆明','东川','曲靖','玉溪','昭通','思茅','临沧','保山','丽江','文山 ','红河 ','西双版纳 ','楚雄 ','大理 ','德宏 ','怒江','迪庆']; <br /> break; <br /> case "西藏": <br /> cities = ['拉萨','那曲','昌都','山南','日喀则','阿里','林芝']; <br /> break; <br /> case "陕西": <br /> cities = ['西安','铜川','宝鸡','咸阳','渭南','延安','汉中','榆林','商洛','安康']; <br /> break; <br /> case "甘肃": <br /> cities = ['兰州','金昌','白银','天水','嘉峪关','定西','平凉','庆阳','陇南','武威','张掖','酒泉','甘南 ','临夏']; <br /> break; <br /> case "青海": <br /> cities = ['西宁','海东',' 海北 ','黄南','海南','果洛','玉树','海西']; <br /> break; <br /> case "宁夏": <br /> cities = ['银川','石嘴山','银南','固原']; <br /> break; <br /> case "新疆": <br /> cities = ['乌鲁木齐','克拉玛依','石河子','吐鲁番','哈密','和田','阿克苏','喀什','克孜勒苏','巴音郭楞','昌吉','博尔塔拉','伊犁']; <br /> break; <br /> case "香港": <br /> cities = ['香港']; <br /> break; <br /> case "澳门": <br /> cities = ['澳门']; <br /> break; <br /> case "台湾": <br /> cities = ['台湾']; <br /> break; <br /> } <br /> for(var i=0;i<cities.length;i++){ <br /> var cityValue = cities[i]; <br /> var option = document.createElement("option"); <br /> var textNode = document.createTextNode(cityValue); <br /> option.appendChild(textNode); <br /> cityElement.appendChild(option); <br /> } <br /> } <br /> </script>

输入不得为空。


    

        

    

 

输入不得为空。


        

        
        
    

    

输入不得为空。


        




<script></script>



<script> <br /> function link(){ <br /> var name = $('#name input').val(); <br /> var danwei = $('#danwei input').val(); <br /> var bumen = $('#bumen input').val(); <br /> var phone = $('#phone input').val(); <br /> if(name=="" || danwei=="" || bumen == "" || phone==""){ <br /> alert('签到信息未完善!') <br /> } <br /> else{ <br /> alert('签到成功!'); <br /> window.location.href='check-in.html'; <br /> } <br /> } <br /></script>

<script></script>
<script> <br /> !window.jQuery&&document.write('<script src="js/jquery.min.js"><\/script>'); <br /></script>
<script></script>

<script> <br /> // 这个脚本是 ie6和ie7 通用的脚本 <br /> function custom_close(){ <br /> if <br /> (confirm("您确定要关闭本页吗?")){ <br /> window.opener=null; <br /> window.open('','_self'); <br /> window.close(); <br /> } <br /> else{} <br /> } <br /></script>


回复讨论(解决方案)

省份信息应该从数据库读取,不要写死,这样会使网页打开变慢。可以通过表单提交,也可以通过javascript发出ajax请求来与后台交互。当然,后台要有相应的处理程序来对你的请求做出响应。

可以把我的代码改成你说的方式发给我吗,我不会改!

前端取数据组装成页面,再将新数据返回给后端。。。。交互使用ajax就可以 了。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template