0

I have a script javascript function to send a value back to a parent page from a hyperlink and then close the modal window that was used to select it.

It works fine in IE but in chrome it does nothing and FF it simply closes the modal window and does not return the value.

I need to get the behaviour all the same across these browsers.

JS Function:

<script type="text/javascript">
    function sendval(value){
        window.top.document.getElementById('txtCustomerType').innerText = value;
        window.parent.closeIframe();
        }
    </script>

ASP Gridview:

        <asp:TemplateField HeaderText="Customer Type">
            <ItemTemplate>
                <a href="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, "CustType") %>');"><%# DataBinder.Eval(Container.DataItem, "CustType") %></a>
            </ItemTemplate>
        </asp:TemplateField>
connersz
  • 1,153
  • 3
  • 23
  • 64

1 Answers1

2

Internet Explorer apparently lets you (incorrectly) use the innerText property to assign to an <input> element's value, but other browsers are not as permissive.

Use the appropriate property, value, instead:

window.top.document.getElementById('txtCustomerType').value = value;
Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479