ASP.NET------jquery

<script type="text/javascript">
                
                regEvents_searchresult();
                function regEvents_searchresult(){
                    $("div[bustypeid]").each(function () {
                        var thisBusType = this;

                        $(this).find("*[buspara='add']").click(function () {

                            var selectid = $(thisBusType).attr("bustypeid");
                            var selectnumber = $(thisBusType).find("*[buspara='selectnumber']").attr("value") * 1;
                            var leftbus = $(thisBusType).find("*[buspara='leftbus']").html() * 1;
                            var brandname = $(thisBusType).find("*[buspara='brandname']").html();
                            var bustypename = $(thisBusType).find("*[buspara='typename']").html();
                            var busseat = $(thisBusType).find("*[buspara='seat']").html();
                            var busnumber = $(thisBusType).find("*[buspara='level']").html();

                            //改变搜索结果内的车辆
                            if (selectnumber <= 0) {
                                alert("所选车辆数不能为0或负数")
                            } else if (selectnumber > leftbus) {
                                alert("选择的车数不能大于剩余车数");
                            }
                            else {
                                $(thisBusType).find("*[buspara='leftbus']").html(leftbus - selectnumber);                            //添加到已选车型
                                var existbus = 0;
                                $("div[selectedbustypeid='" + selectid + "']").each(function () {
                                    existbus++;
                                })
                                if (existbus == 0) {
                                    $("#selectedbusarea").append(
                                        '<div class="selectedbusitem" selectedbustypeid="' + selectid + '">' +
                                            '<a class="selectedbusitem_t" >' + bustypename + '</a>' +
                                            '<span class="selectedbusitem_text">' +
                                                '车座数:' +
                                                '<span style="font-weight:bold;font-family:arial;font-size:14px;color:#188718;">' + busseat + '</span>' +
                                                '座' +
                                            '</span>' +
                                            '<span class="selectedbusitem_text">' +
                                                '预订车辆数:' +
                                                '<span style="font-weight:bold;font-family:arial;font-size:13px;color:#188718;" selectedbuspara="selectednumber">' + selectnumber + '</span>' +
                                                '辆' +
                                            '</span>' +
                                            '<div class="deletebus"><a href="javascript:" id="LASTCREATEDELEMENT" deleteselectedbusid="' + selectid + '">取消选择</a></div>' +
                                            '<div class="line"></div>' +
                                        '</div>'
                                    )
                                    $("#LASTCREATEDELEMENT").click(function () {
                                        var leftbus2 = $('div[bustypeid=' + $(this).attr("deleteselectedbusid") + ']').find("*[buspara='leftbus']").html() * 1;
                                        var selectedbus2 = $('div[selectedbustypeid=' + $(this).attr("deleteselectedbusid") + ']').find("*[selectedbuspara='selectednumber']").html() * 1;
                                        $('div[selectedbustypeid=' + $(this).attr("deleteselectedbusid") + ']').remove();
                                        $('div[bustypeid=' + $(this).attr("deleteselectedbusid") + ']').find("*[buspara='leftbus']").html(leftbus2 + selectedbus2)
                                    })
                                    $("#LASTCREATEDELEMENT").removeAttr("id")
                                } else {
                                    var selectedbusnumber = $("div[selectedbustypeid=" + selectid + "]").find("*[selectedbuspara='selectednumber']").html() * 1
                                    $("div[selectedbustypeid=" + selectid + "]").find("*[selectedbuspara='selectednumber']").html(
                                        selectedbusnumber + selectnumber
                                    )
                                }
                            }
                        })

                    })
                }
                
                searchbustypebottonclick();
            </script>

最近在忙的一些事....

posted @ 2011-08-12 10:19  brainmao  阅读(408)  评论(0编辑  收藏  举报