码迷,mamicode.com
首页 > 其他好文 > 详细

添加数据

时间:2018-07-29 23:20:10      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:meta   html   device   http   input   cli   type   checked   view   

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <script src="~/Scripts/jquery-1.7.2-min.js"></script>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script type="text/javascript">
        $(function ()
        {
            $.ajax({
                url: http://localhost:8889/SchoolWebserice.asmx/GetSchools‘,
                type: post‘,
                
                success: function (data)
                {
                    $(data).each(function (index, data)
                    {
                        $("#s").append("<option value=‘"+data.SchoolCode+"‘>"+data.SchoolName+"</option>")
                    })
                }
            })
            $("#s").change(function ()
            {
                $.ajax({
                    url: http://localhost:8889/ClassWebService.asmx/GetClasses‘,
                    type: post‘,
                    data:{
                        SchoolCode:$("#s").val()
                    },
                    success: function (data) {
                        $("#c option").not(":first").remove();
                        $(data).each(function (index, data) {
                            $("#c").append("<option value=‘" + data.ClassCode + "‘>" + data.ClassName + "</option>")
                        })
                    }
                })
            })
            $("#Addbtn").click(function ()
            {
                $.ajax({
                    url: http://localhost:8889/StudentWebService.asmx/Add‘,
                    type: post‘,
                    data: {
                        SchoolCode: $("#s").val(),
                        ClassCode: $("#c").val(),
                        StudentName: $("input[name=StudentName]").val(),
                        Gender:$(":radio:checked").val()
                    },
                    success: function (data)
                    {
                        if (data > 0) {
                            alert("添加成功")
                        }
                        else {
                            alert(添加失败‘)
                        }
                    }
                })
            })
            $("#Button1").click(function ()
            {
                location.href = /Student/Show‘;
            })


        })
    </script>
</head>
<body>
   <table>
       
       <tr>
           <td>
               学校名称
           </td>
           <td>
               <select id="s" >
                   <option value="0">请选择</option>

               </select>
           </td>
       </tr>
       <tr>
           <td>
               班级名称
           </td>
           <td>
               <select id="c">
                   <option value="0">请选择</option>

               </select>
           </td>
       </tr>
       <tr>
           <td>学生姓名</td>
           <td>
               <input type="text" name="StudentName" />
           </td>
       </tr>
       <tr>
           <td>学生性别</td>
           <td>
               <input id="Radio1" type="radio"value="0"name="Gender" checked="checked"/><input id="Radio1" type="radio" value="1"name="Gender"/></td>
       </tr>
       <tr>
           <td>
               <input id="Addbtn" type="button" value="保存" />
               <input id="Button1" type="button" value="返回" />
           </td>
       </tr>
   </table>
</body>
</html>

 

添加数据

标签:meta   html   device   http   input   cli   type   checked   view   

原文地址:https://www.cnblogs.com/mamingyuan/p/9387972.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!