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

Setting a value of the textbox

2 Answers 107 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 26 Nov 2013, 10:13 PM
Hi,
I have a following problem. First code:
<telerik:RadPanelBar runat="server" ID="RadPanelBar2" ExpandMode="SingleExpandedItem" Width="100%">
            <Items>
                <telerik:RadPanelItem ImageUrl="~/Images/Att.png" Text="MojAtak" runat="server" Expanded="True">
                    <Items>
                        <telerik:RadPanelItem runat="server">
                            <ItemTemplate>
                                <asp:TextBox ID="ReportBox" class="text" runat="server" Style="height: 99%; width: 98%; font-size: 9px; border-style: none;" TextMode="MultiLine" onkeyup="javascript: czytaj();"></asp:TextBox>
                                <asp:TextBox ID="txtKto" runat="server" class="text" Height="14px" Style="width: 140px;" Font-Size="Small" BackColor="#CCFFFF" Font-Italic="True"></asp:TextBox>
                            </ItemTemplate>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelItem>
 
                <telerik:RadPanelItem ImageUrl="~/Images/Cone.png" Text="Outbox" runat="server">
                    <Items>
                        <telerik:RadPanelItem runat="server">
                            <ItemTemplate>
                                <asp:TextBox ID="txtKogoS" runat="server" class="text" Height="14px" Style="width: 140px;" Font-Size="Small" ReadOnly="True" BackColor="#CCFFFF" Font-Italic="True"></asp:TextBox>
                                <asp:TextBox ID="txtDataS" runat="server" class="text" Height="14px" Style="width: 140px;" Font-Size="Small" ReadOnly="True" BackColor="#CCFFFF" Font-Italic="True"></asp:TextBox>
                            </ItemTemplate>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>
 
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
            <script type="text/javascript">
                var ReportBox = '<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("ReportBox")).ClientID%>';
                var KtoBox = '<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("txtKto")).ClientID%>';
                function czytaj() {
 
                    alert($get(ReportBox).value);
 
                    var raport = $get(ReportBox).value;
                    if (raport.search("ygraÅ‚") > 0 || raport.search("z walki:") > 0 || raport.search("Remis") >= 0) {
                        alert("Kto");
                        //kto
                        var k1 = raport.indexOf("w.", 0);
                        var wynikS = raport.substring(k1 + 3);
                        var k2 = wynikS.indexOf("otrzyma", 0);
                        var kto = wynikS.substring(0, k2 - 1);
                        alert(kto);
                        alert(KtoBox);
 
                    } else {
                        alert("!!!!");
                    }
                }
            </script>
        </telerik:RadScriptBlock>

onkeyup - I can access whatever user entered in the ‘ReportBox’ but I can’t update ‘txtKto’.

If anyone have any suggestion please go ahead. Oh and please keep in mind I'm a rookie.

Thank you

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Nov 2013, 05:37 AM
Hi John,

I guess you want to update the TextBox 'txtKto' value based on the value of 'ReportBox' TextBox. Please have a look into the following JavaScript which works as expected for me.

JavaScript:
<script type="text/javascript">
    var ReportBox = '<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("ReportBox")).ClientID%>';
    var KtoBox = document.getElementById('<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("txtKto")).ClientID%>');
    function czytaj() {
        alert($get(ReportBox).value);
        var raport = $get(ReportBox).value;
        if (raport.search("test") == 0) {
            KtoBox.value = raport;
        }
        else {
            alert("!!");
        }
    }
</script>

Let me know if you have any concern.
Thanks,
Shinu.
0
John
Top achievements
Rank 1
answered on 27 Nov 2013, 06:25 PM

Thank you Shinu, worked like a charm.

Regards

Tags
PanelBar
Asked by
John
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or