Reputation: 2060
I am not sure if you can do this, but if not please provide me with a simple work around if possible. I am want the user to select an img (id of 'cowboys' or 'giants'). I want to get the value of these (which are both 'One') and return that into the id 'scenario'. Everything else works except this part and I have a feeling it is bc you can't do it. So any suggestions would be depreciated!
<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>
Upvotes: 0
Views: 132
Reputation: 178126
Change
document.getElementById("team").innerHTML = x.id;
document.getElementById("team").innerHTML = x.value;
to
document.getElementById("team").innerHTML = x.id;
document.getElementById("scenario").innerHTML = x.name;
Upvotes: 1
Reputation: 13003
You can also use expando attribute so you can add custom attributes like 'value' and read it using JavaScript/jQuery.
Upvotes: 0
Reputation: 2311
value
is an attribute that can only be applied to form elements, like input
. If you want to get a simple attribute, use name
.
Upvotes: 3