[RESOLVED]Javascript variable in a textbox not working

Hello,

I have a javascript code :

        function replaceSelectedText() {
            var sel, range;
            var newValue;
            if (window.getSelection) {
                sel = window.getSelection();
                if (sel.rangeCount) {
                    newValue = "<a href="#" onclik="Showpopup(" + document.getElementById('<%= ddlWettekstLink.ClientID %>').value + ")">" + sel + "</a>"
                    range = sel.getRangeAt(0);
                    range.deleteContents();
                    range.insertNode(document.createTextNode(newValue));
                }
            } else if (document.selection && document.selection.createRange) {
                range = document.selection.createRange();
                range.text = replacementText;
            }
        }

When I select some text
and i wants to
be replace if for the
new variable
into an
asp:
textbox it will not be
replaced. If I use a
asp: label then
it will succeed ?????

Does anyone know a solution?

Sincerely,

Mark

Hi Mark,

I suggest that you can first set a breakpoint  on the javascript function above ,then press F12 to debug it ,when you select the textbox  see if it has any error message.

Then it would be better for us ,if you can post the code which can reproduce your issue for us ,so that I can test it in my side.

Best Regards,

Kevin Shen.

Leave a Reply