J
joe
I'm trying to get a target value from an option -control.
Sample code that works in FireFox but on IE 9 or IE 6 (I haven't tested others):
<HTML><HEAD></head><body>
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
function mytest(eventTarget, eventObject)
{
var str1,test;
str1=eventObject.target.value;
test=document.getElementById("ab");
test.innerHTML=str1;
}
</SCRIPT>
<select onclick="mytest(this,arguments[0])">
<option value="bla" >One</option>
<option value="blu" >Two</option>
<option value="yel" >Three</option>
</select>
<div id="ab" style="position:absolute; left: 100px;top:100px;width: 200px;height:
100px;">
Testing</div>
</BODY></HTML>
After Googling around I found some info that I could use like this:
<HTML><HEAD></head><body>
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
function mytest(event)
{
var str1,test;
var target= event.target || event.srcElement;
str1=target.options[target.selectedIndex].value;
test=document.getElementById("ab");
test.innerHTML=str1;
};
</SCRIPT>
<select onclick="mytest(arguments[0])">
<option value="bla" >One</option>
<option value="blu" >Two</option>
<option value="yel" >Three</option>
</select>
<div id="ab" style="position:absolute; left: 100px;top:100px;width: 200px;height:
100px;">
Testing</div>
</BODY></HTML>
Unfortunately it works only on FF but not IE.
What can I try next?
Sample code that works in FireFox but on IE 9 or IE 6 (I haven't tested others):
<HTML><HEAD></head><body>
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
function mytest(eventTarget, eventObject)
{
var str1,test;
str1=eventObject.target.value;
test=document.getElementById("ab");
test.innerHTML=str1;
}
</SCRIPT>
<select onclick="mytest(this,arguments[0])">
<option value="bla" >One</option>
<option value="blu" >Two</option>
<option value="yel" >Three</option>
</select>
<div id="ab" style="position:absolute; left: 100px;top:100px;width: 200px;height:
100px;">
Testing</div>
</BODY></HTML>
After Googling around I found some info that I could use like this:
<HTML><HEAD></head><body>
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
function mytest(event)
{
var str1,test;
var target= event.target || event.srcElement;
str1=target.options[target.selectedIndex].value;
test=document.getElementById("ab");
test.innerHTML=str1;
};
</SCRIPT>
<select onclick="mytest(arguments[0])">
<option value="bla" >One</option>
<option value="blu" >Two</option>
<option value="yel" >Three</option>
</select>
<div id="ab" style="position:absolute; left: 100px;top:100px;width: 200px;height:
100px;">
Testing</div>
</BODY></HTML>
Unfortunately it works only on FF but not IE.
What can I try next?