views:

115

answers:

1

I am just testing the brand new Internet Explorer 9 Beta with my website. I see a weird behaviour for some form values and I am not sure if it is my mistake or a bug in IE9. What do you think?

I have one form which declares several hidden input fields like this

<input type="hidden" name="NewStatus" />
<input type="hidden" name="lastSaveStatus" value="" />

When the page is being submitted, the values are saved like this (in JavaScript):

newStatus.setAttribute("value", myNewStatus);
var formLastStatus = document.getElementsByName("lastSaveStatus")[0];
formLastStatus.setAttribute("value", lastSaveStatus);
alert(lastSaveStatus);
alert(formLastStatus.getAttribute("value"));
var form = document.getElementById("myForm"); 
form.submit();

That code has worked for years and across all browsers. The alerts already indicate that I have now a problem with the lastSaveStatus field. In IE9 the NewStatus is correctly transmitted to the server (means that I can access the value in ASP.NET using Request.Form["NewStatus"]). But the value for "lastSaveStatus" is always "".

As you can see I used a value="" in the definition of my hidden field. If I remove this default value, the new value is correctly transferred to the server. If I use a default value, always the default value is transferred.

Any idea why this is happening?

A: 

Are you sure this worked in previous versions of IE? I've always had problems with that syntax in IE/Win, the following should work however:

formLastStatus.value = lastSaveStatus;

The above should work in all browsers, too.

Dean Harding
Yes I am VERY sure that it works in IE6, 7, 8. It also works in 9 with the NewStatus value which also uses setAttribute. By the way, the alert(formLastStatus.getAttribute("value")); does alert the correct, new value. But this value is not transferred but the default value is.
newtogit