哪位大哥帮忙看一下,这个是实现星星评分.去掉  <form id="form1" runat="server"></form>就能正常运行,否则就会报
“行: 0错误: 对象不支持此属性或方法”这个错误,谢谢
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Detail_Comment.aspx.cs"Inherits="DetailMouldManagerment.Detail_Comment" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>    <script type="text/javascript">
        var flag = 0 //评分标记  
        function showRate(name, input, comment, display, title) { //name:对象名 input:隐藏表单名
            this.name = name;   //对象名称
            this.length = 5;    //总分数 (默认为5)
            this.score = 2;     //当前分数 (默认为2)
            this.times = 1;     //打印次数
            this.display = display; //是否有评分内容
            this.comment = comment; //评分内容  1 有,0没有
            var temp = "";
            document.write(title + '<span id="rate" class="rate"></span>');
            document.write('<input id="' + input + '" name="' + input + '" type="hidden" value="0" />');
            this.inputElement = document.getElementById(input);
        }
        //输出
        showRate.prototype.print = function(urlid, dbid, deptid) { //显示
            var output = '', classname = '';
            this.urlid = urlid;
            this.dbid = dbid;
            this.deptid = deptid;
            for (var i = 1; i <= this.length; i++) {
                if (i <= this.score) {
                    classname = 'rate-default';
                }
                else {
                    classname = 'rate-off';
                }
                if (this.display == "1") {
                    output += '<a id="rate_' + i + '" name="rate_' + i + '" href="#"  onclick="return ' + this.name + '.saveRate(event,\'' + urlid + '\',\'' + dbid + '\',\'' + deptid + '\',' + i + ');" onmouseover="return ' + this.name + '.setRate(event, ' + i + ');" onmouseout="return ' + this.name + '.setRate(event, ' + i + ');" class="' + classname + '">&nbsp;</a>';
                }
                else {
                    output += '<a id="rate_' + i + '" name="rate_' + i + '" href="#"  onclick="return ' + this.name + '.saveRate(event,\'' + urlid + '\',\'' + dbid + '\',\'' + deptid + '\',' + i + ');" onmouseover="return ' + this.name + '.setRate(event, ' + i + ');" onmouseout="return ' + this.name + '.setRate(event, ' + i + ');" class="' + classname + '" title=分数:' + i + "分>&nbsp;</a>";
                }
            }            document.getElementById('rate').innerHTML = output;
        }
        //保存
        showRate.prototype.saveRate = function(ev, urlid, dbid, deptid, score) {
            var temp = "";
            var output = '';
            if (flag == "1");
            {
                alert("您已经评过分了");
                return;
            }
            document.getElementById("sLength").value = this.length;
            document.getElementById("sScore").value = score;
            for (var i = 1; i <= this.length; i++) {
                if (i <= score) {
                    classname = 'rate-default';
                } else {
                    classname = 'rate-off';
                }
                output += '<a id="rate_' + i + '" name="rate_' + i + '" href="#"  onclick="return ' + this.name + '.saveRate(event,\'' + this.urlid + '\',\'' + this.dbid + '\',\'' + this.deptid + '\',' + i + ');" onmouseover="return ' + this.name + '.setRate(event, ' + i + ');" class="' + classname + '" title="Rate:' + i + '">&nbsp;</a>';
            }
            document.getElementById('rate').innerHTML = output;
            var objPos = mousePosition(ev);
            if (this.display == "1") {
                showMessageBox('评论', "<div id='rateCount'><div>写评论: <textarea id=\"ta_content\" cols=\"20\" rows=\"5\" value=" + this.comment + "></textarea></div><br/><div>&nbsp;&nbsp;&nbsp;<input type='button' id='bt_submit' value='确定' onclick=" + this.name + ".comtentSubmit() />&nbsp;&nbsp;&nbsp; <input type='button' id='bt_submit' value='取消' onclick='comtentClose()' /></div></div>", objPos, 245);
            }
            else {
                this.comtentSubmit();
            }
        }
        //提交
        showRate.prototype.comtentSubmit = function() {
            if (document.getElementById("ta_content") == null) temp = ""; else temp = document.getElementById("ta_content").value;
            var score = document.getElementById("sScore").value;
            $.ajax({
                url: "../AjaxHandler/DetailHandler.ashx",
                data: { score: score, type: "SaveStar", urlid: this.urlid, dbid: this.dbid, deptid: this.deptid, content: encodeURIComponent(temp) },
                beforeSend: beforeLoad,
                success: this.handleResponse,
                async: false,
                dataType: "Json"
            });        }
        var beforeLoad = function() {
            //提交过程中的状态  后期在写
        }
        //提交成功后
        showRate.prototype.handleResponse = function(value) {
            var output = '';
            if (value.split('_')[0] == "R") {
                alert("您已经评过分了!");
                var length = document.getElementById("sLength").value;
                var score = value.split('_')[1];
                for (var i = 1; i <= length; i++) {
                    if (i <= score) {
                        classname = 'rate-default';
                    } else {
                        classname = 'rate-off';
                    }
                    output += '<a id="rate_' + i + '" name="rate_' + i + '" href="#"   class="' + classname + '" title="分数:' + i + '分">&nbsp;</a>';
                }
                document.getElementById('rate').innerHTML = output;                closeWindow();
            }
            else if (value.length > 5) {
                window.location = value;
            }
            else {
                var output = '';
                var length = document.getElementById("sLength").value;
                var score = value;
                for (var i = 1; i <= length; i++) {
                    if (i <= score) {
                        classname = 'rate-default';
                    } else {
                        classname = 'rate-off';
                    }
                    output += '<a id="rate_' + i + '" name="rate_' + i + '" href="#"   class="' + classname + '" title="分数:' + i + '分">&nbsp;</a>';
                }
                document.getElementById('rate').innerHTML = output;
                alert("评分已成功!");
                closeWindow();
            }
        }
        showRate.prototype.setRate = function(evt, id) { //设置分数
            evt = evt ? evt : (window.event ? window.event : null);
            evt = evt.type;
            switch (evt) {
                case 'mouseover':
                    onNumber = id;
                    break;
                case 'mouseout':
                    onNumber = this.score;
                    break;
                case 'click':
                    this.score = id;
                    onNumber = this.score;
                    break;
                default:
                    return;
            }
            this.inputElement.value = onNumber;
            for (var i = 1; i <= this.length; i++) {
                var e = document.getElementById('rate_' + i);
                if (i <= onNumber) {
                    e.className = 'rate-default';
                }
                else {
                    e.className = 'rate-off';
                }
            }
            this.times++;
            window.status = '';
            return true;
        }
        var comtentClose = function() {
            closeWindow();
        }
        //-->
    </script>    <style type="text/css">
        body, div, a
        {
            font-size: 9px;
            font-family: Tahoma, sans-serif;
            text-decoration: none;
            text-align: center;
        }
        a:hover
        {
            color: #FF6600;
            text-decoration: underline;
        }
        /* Rate Style */.rate
        {
            width: 209px;
            padding: 3px 0px;
            height: 29px;
        }
        .rate a.rate-on, .rate a.rate-off, .rate a:hover.rate-on, .rate a:hover.rate-off, .rate a.rate-default, .rate a:hover.rate-default
        {
            font-size: 10px;
            font-family: Tahoma, Verdana;
            background-position: center center;
            background-repeat: no-repeat;
            text-decoration: none;
            padding: 2px 7px;
        }
        .rate a.rate-on, .rate a:hover.rate-on
        {
            background-image: url(SavedStar.png);
        }
        .rate a.rate-off, .rate a:hover.rate-off
        {
            background-image: url(EmptyStar.png);
        }
        .rate a.rate-default, .rate a:hover.rate-default
        {
            background-image: url(FilledStar.gif);
        }
    </style>
</head>
<body>
        <form id="form1" runat="server">
        <script type="text/javascript">
            var rate = new showRate('rate', 'rate', '提示', '1', 'Title');  //name:对象名 input:隐藏表单名
            rate.length = 10;   //总分数 (默认为5)
            rate.score = 3;    //当前分数 (默认为2)
            rate.print('77b833285a5fa827aff333786fbca638', '5.', '12');      //显示
        </script>
        </form>
    </div>
</body>
</html>

解决方案 »

  1.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Detail_Comment.aspx.cs"
        Inherits="DetailMouldManagerment.Detail_Comment" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title></title>    <script src="jquery-1.3.2.min-vsdoc.js" type="text/javascript"></script>    <script type="text/javascript">
            function showRate(name, input) { //name:对象名 input:隐藏表单名
                this.name = name;   //对象名称
                this.length = 5;    //总分数 (默认为5)
                this.score = 2;     //当前分数 (默认为2)
                this.times = 1;     //打印次数
                document.write('<div id="rate" class="rate"></div>');
                document.write('<input id="' + input + '" name="' + input + '" type="hidden" value="0" />');            this.inputElement = document.getElementById(input);
            }        showRate.prototype.print = function(urlid, dbid, deptid) { //显示
                var output = '', classname = '';
                for (var i = 1; i <= this.length; i++) {
                    if (i <= this.score) {
                        classname = 'rate-default';
                    } else {
                        classname = 'rate-off';
                    }
                    output += '<a id="rate_' + i + '" name="rate_' + i + '" href="#" onclick="return ' + this.name + '.saveRate(event,\'' + urlid + '\');" onmouseover="return ' + this.name + '.setRate(event, ' + i + ');" onmouseout="return ' + this.name + '.setRate(event, ' + i + ');" class="' + classname + '" title="Rate:' + i + '">&nbsp;</a>';
                }
                document.getElementById('rate').innerHTML = output;
            }
            showRate.prototype.saveRate = function(evt, id) {
                $.ajax({                url: "text.ashx",
                    processData: false,
                    data: { id: id },
                    beforeSend: beforeLoad,
                    success: handleResponse,
                    async: false,
                    dataType: "text"
                });
            }
            var beforeLoad = function() {        }
            var handleResponse = function() {        }
            showRate.prototype.setRate = function(evt, id) { //设置分数
                evt = evt ? evt : (window.event ? window.event : null);
                evt = evt.type;
                switch (evt) {
                    case 'mouseover':
                        onNumber = id;
                        break;
                    case 'mouseout':
                        onNumber = this.score;
                        break;
                    case 'click':
                        this.score = id;
                        onNumber = this.score;
                        break;
                    default:
                        return;
                }
                this.inputElement.value = onNumber;
                for (var i = 1; i <= this.length; i++) {
                    var e = document.getElementById('rate_' + i);
                    if (i <= onNumber) {
                        if (this.times == 1)
                            e.className = 'rate-default';
                        else
                            e.className = 'rate-on';
                    }                else {
                        e.className = 'rate-off';
                    }
                }
               
                this.times++;
                window.status = '';
                return true;
            }
            //-->
        </script>    <style type="text/css">
            body, div, a
            {
                font-size: 9px;
                font-family: Tahoma, sans-serif;
                text-decoration: none;
                text-align: center;
            }
            a:hover
            {
                color: #FF6600;
                text-decoration: underline;
            }
            /* Rate Style */.rate
            {
                width: 209px;
                padding: 3px 0px;
                height: 29px;
            }
            .rate a.rate-on, .rate a.rate-off, .rate a:hover.rate-on, .rate a:hover.rate-off, .rate a.rate-default, .rate a:hover.rate-default
            {
                font-size: 10px;
                font-family: Tahoma, Verdana;
                background-position: center center;
                background-repeat: no-repeat;
                text-decoration: none;
                padding: 2px 7px;
            }
            .rate a.rate-on, .rate a:hover.rate-on
            {
                background-image: url(SavedStar.png);
            }
            .rate a.rate-off, .rate a:hover.rate-off
            {
                background-image: url(EmptyStar.png);
            }
            .rate a.rate-default, .rate a:hover.rate-default
            {
                background-image: url(FilledStar.gif);
            }
        </style>
    </head>
    <body>
        <form runat="server" id="aspnetform">    <script type="text/javascript">
            var rate = new showRate('rate', 'rate');
            rate.length = 10;   //总分数 (默认为5)
            rate.score = 3;    //当前分数 (默认为2)
            rate.print('77b833285a5fa827aff333786fbca638', '5.', '12');      //显示
        </script>    </form>
    </body>
    </html> 这回少了,就是找不到原因,所以才郁闷,在FF在可以,在IE 下就是错误
      

  2.   

    楼主想问什么? 既然去掉FORM能正常运行了,就让它正常运行呗。
      

  3.   


    <form id="form1" runat="server"></form>就能正常运行
    想干什么,像将数据提交的后台么。
    如果是要提交到后台可以用js取值,然后url传参传递到后台。
      

  4.   

    嗯,所看的只是整体中评分模块,整体的页面还有不少的服务器控件,没办法去掉form ,现在只有找到原因在什么地方。