0

我不确定您是否可以这样做,但如果不能,请尽可能为我提供一个简单的解决方法。我希望用户选择一个 img('cowboys' 或 'giants' 的 id)。我想获取这些值(它们都是“一”)并将其返回到 id“场景”中。除了这部分,其他一切都有效,我有一种感觉,因为你做不到。所以任何建议都会被贬低!

        <script type="text/javascript">
        //this is the user id session stored as a javascript variable
        var userid = "<?=$id?>";

        function bigimg(x) {
            var myDate = new Date(); // Your timezone! 
            var myEpoch = myDate.getTime()/1000; 
            var deadline = '1344700055.000'; 
                //determines if user was on time..if not on time hover enlarge won't work
                if(myEpoch < deadline) {
                    x.style.height="65px";
                    x.style.width="85px";
                    x.style.opacity="0.5";
                } else {}
        }
        function defaultimg(x) {
            x.style.height="60px";
            x.style.width="80px";
            x.style.opacity="1.0";
        }
        function teamback(x) {
            var myDate = new Date(); // Your timezone! 
            var myEpoch = myDate.getTime()/1000; 
            var deadline = '1344700055.000';
                //determines if user was on time..if not on time submitting won't work
                if(myEpoch > deadline) {
                    // update the "actualone" image's source to the sending-image's source
                    document.getElementById("actualone").src = x.src;
                    document.getElementById("curtime").innerHTML = myEpoch;
                    document.getElementById("team").innerHTML = x.id;
                    document.getElementById("team").innerHTML = x.value;
                } else {}           
        }
        </script>

    </head>
        <body>
            Your Team<br>
            <iframe style="background-color:red;" src="http://free.timeanddate.com/countdown/i38ik9yz/n417/cf12/cm0/cu4/ct1/cs1/ca0/co1/cr0/ss0/cac000/cpc000/pct/tc66c/fs100/szw320/szh135/tatTime%20Remaining%20to%20Make%20Picks/tac000/tptTime%20since%20Event%20started%20in/tpc000/iso2012-08-11T13:00:00" frameborder="0" width="236" height="36"></iframe>

            <br><img id="cowboys" value="One" onmouseover="bigimg(this)" onclick="teamback(this)" onmouseout="defaultimg(this)" src="cowboys.gif"> vs <img id="giants" value="One" onmouseover="bigimg(this)" onclick="teamback(this)" onmouseout="defaultimg(this)" src="giants.gif"><img src="" id="actualone" style="width:85px; height:65px;"><br><br>
            <img src="colts.gif"> vs <img src="bears.gif">
            <div id="curtime">44</div>|||<div id="deadline"></div><br><div id="team">Team</div><div id="scenario">Scenario</div>


        </body>
</html>
4

3 回答 3

3

value是一个只能应用于表单元素的属性,例如input. 如果您想获得一个简单的属性,请使用name.

于 2012-08-12T05:50:03.433 回答
1

改变

document.getElementById("team").innerHTML = x.id;
document.getElementById("team").innerHTML = x.value;

document.getElementById("team").innerHTML = x.id;
document.getElementById("scenario").innerHTML = x.name;
于 2012-08-12T05:52:14.070 回答
0

您还可以使用expando属性,这样您就可以添加自定义属性,如“值”并使用 JavaScript/jQuery 读取它。

于 2012-08-12T05:53:50.230 回答