我不確定您是否可以這樣做,但如果不能,請儘可能爲我提供簡單的解決方法。我希望用戶選擇一個img('cowboys'或'巨人'的id)。我想獲得這些(都是'一')的價值,並將其返回到id'場景'中。除了這部分,其他一切都有效,我有一種感覺,就是BC,你不能這樣做。所以任何建議都會貶值!獲取img的價值
<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>
這並不完全清楚你在問什麼。你能把你的例子縮小到你想要做的一小部分嗎? 「圖像的價值」並不是那麼有意義。你的意思是原始圖像數據?圖片名稱或網址?此外,在查詢中使用時,您確實應該轉義您的數據。最好的情況是,你會偶爾遇到SQL中的錯誤,最壞的情況是你會打開SQL注入漏洞。我建議學習使用PDO準備好的查詢。 – Brad 2012-08-12 05:47:28
場景在哪裏?你有兩個團隊:document.getElementById(「team」)。innerHTML = x.id; document.getElementById(「team」)。innerHTML = x.value; – mplungjan 2012-08-12 05:48:25
'我想要得到這些的價值(哪一個都是'一')。'你是什麼意思的價值的圖像? – 2012-08-12 05:49:13