This is a migrated thread and some comments may be shown as answers.

Can't change text on button via javascript.

7 Answers 521 Views
FormDecorator
This is a migrated thread and some comments may be shown as answers.
Christopher Bishop
Top achievements
Rank 2
Christopher Bishop asked on 23 Nov 2008, 09:50 PM
document.getElementById('testbutton').value = "fred";

does not work on buttons?

in html
<input id="testbutton" style="text-align: left;width:74px;" type="button" value="My Test Button" />

in javascript
document.getElementById('testbutton').value = "fred";

Does not change the text on the button, remove the formdecorator and it works fine...

Any ideas?

7 Answers, 1 is accepted

Sort by
0
Christopher Bishop
Top achievements
Rank 2
answered on 23 Nov 2008, 10:12 PM
I sure hope there is a function I can call instead of this

document.getElementById(

'Skinnedtestbutton').innerHTML = '<SPAN class="radfdOuterSpan"><SPAN class="radfdInnerSpan">Hello World</span></span>';

 

0
Martin
Telerik team
answered on 24 Nov 2008, 12:05 PM
Hello Christopher Bishop,

Try the following function, I believe it will work for you:

function

 

changeText(SkinnedBtnId, NewText)
{
    var
button = document.getElementById(SkinnedBtnId).childNodes[0];
    button.childNodes[0].innerHTML = NewText;
}

 

Regards,
Martin Ivanov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Backtell
Top achievements
Rank 1
answered on 04 Jan 2009, 04:02 AM
This doesn't seem to work for me, especially on a ASP.NET button. Do you have any other suggestions? The first childNodes returns 'undefined'.
0
Martin
Telerik team
answered on 05 Jan 2009, 06:26 AM
Hello Backtell,

It is strange why this does not work for you. Is it possible that you send me a sample project with your particular scenario and the script that changes the text of the button so I am able to help?

All the best,
Martin Ivanov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christopher Bishop
Top achievements
Rank 2
answered on 05 Jan 2009, 01:47 PM
Whats the code look like that you are calling? Sounds like it isn't working because of a ID problem.
0
Chris Castle
Top achievements
Rank 1
answered on 04 Feb 2009, 05:33 AM

I am having this problem as well.  Can someone post a full example for an button that is runat="server" like below?

<

 

asp:Button ID="btnSave" runat="server" Text="Save" />

 

0
Georgi Tunev
Telerik team
answered on 04 Feb 2009, 08:47 AM
Hello Chris,

Here is now to do this:
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
        <script type="text/javascript"
            function changeText(button) 
            { 
                var decoratedbutton = "_radfd_Skinned" + button.id;//allternative: var decoratedbutton = "_radfd_Skinned" + "<%= Button1.ClientID %>"; 
                $get(decoratedbutton).childNodes[0].childNodes[0].innerHTML = "Text changed";             
            } 
        </script> 
 
        <telerik:RadFormDecorator ID="RadFormDecorator1" Visible="true" DecoratedControls="all" 
            runat="server" /> 
        <asp:Button ID="Button1" runat="server" Text="Test Button" OnClientClick="changeText(this); return false" /> 
    </form> 


Best wishes,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
FormDecorator
Asked by
Christopher Bishop
Top achievements
Rank 2
Answers by
Christopher Bishop
Top achievements
Rank 2
Martin
Telerik team
Backtell
Top achievements
Rank 1
Chris Castle
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or