...

View Full Version : Accessing Objects in IE6 and IE7



Nevo
06-08-2008, 06:13 PM
Hi

I have problem with accessing objects in IE7 while in IE6 everything works fine.

Following code works fine with IE6. The value of the element (dropdown list) is accessed correctly and the value of each selected option is correctly writen on the page.
In IE7 the value of first option is writen on the page and it will not change when I select another option from dropdown list.

This does not work even with getElementById.



<script language=javascript>
document.write("<form name='selection'>Select:");
document.write("<select name='SEL' onchange='history.go(0)'>");
document.write("<option value=1>400</option>");
document.write("<option value=2>500</option>");
document.write("<option value=3>600</option>");
document.write("</select></form>");
document.write(document.selection.SEL.value);
</script>


Can someone pls help to bring a light into this.

Thx

Nevo

Arty Effem
06-09-2008, 01:54 PM
document.write("<select name='SEL' onchange='history.go(0)'>");
Whenever you change the option you call history.go(0), which will reload the page.
What do you expect to happen?

Nevo
06-09-2008, 05:39 PM
Thx for input.
Yes, I know. But the weird thing is that it works in IE6 and Firefox.
You can try it. All the time when you make the selection and the page is reloaded the value changes. This is not true in IE7.

In IE7 I need to call function and put the value somewhere - e.g. using innerHTML.
I mean it works for IE7 only this way (all what I found out yet):



<script language=javascript>
document.write("<form name='selection'>Select:");
document.write("<select id='SEL' onchange='Fnc()'>");
document.write("<option value=1>400</option>");
document.write("<option value=2>500</option>");
document.write("<option value=3>600</option>");
document.write("</select></form>");

function Fnc(){
var sel=document.getElementById('SEL');
document.getElementById('p')innerHTML=sel.value;
}
</script>

<p id='p'></p>


I need this functionality but without calling function. Can this be done in IE7?

Thx for any advice.

Nevo

Arty Effem
06-09-2008, 08:55 PM
I need this functionality but without calling function. Can this be done in IE7?
Reloading a page and expecting an element's value to be preserved is inadvisable.
Your way is acceptable and there's no way to do it without calling some function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum