Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have textbox whose text is assign through checkbox item selected
using javascript.
I also have two dropdown whose value is interdependent each other which is assign through .cs server code in c#.
while selecting dropdown value textbox value lost.
how i retain textbox value ?????

i already used update panel and save checkbox selected value in hidden field and then assign it to textbox in javascript.
textbox is readonly

help me

Javascript function:

XML
<script type="text/javascript">

     function Checkinternationallocation(checkBoxList) {
         var options = checkBoxList.getElementsByTagName('input');
         var arrayOfCheckBoxLabels = checkBoxList.getElementsByTagName("label");
         var s = "";

         for (i = 0; i < options.length; i++) {
             var opt = options[i];
             if (opt.checked) {
                 s = s + ", " + arrayOfCheckBoxLabels[i].innerText;
             }
         }
         if (s.length > 0) {
             s = s.substring(2, s.length); //sacar la primer 'coma'
         }
         var TxtBox = document.getElementById("<%=txt_combo_international_location.ClientID%>");
         TxtBox.value = s;
         document.getElementById('<%=hide_international_location.ClientID %>').value = s;
     }

 </script>



:html code for textbox:


XML
<div class="rightPositioncontrol">
                  
                           <asp:TextBox ID="txt_combo_location" runat="server" Width="450" onChange="tab();"  ToolTip="Location(s) of Job"></asp:TextBox>
                           <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender5" runat="server" TargetControlID="txt_combo_location"
                               WatermarkText="Select Location(s) of Jobs" WatermarkCssClass="watermarked" />
                           <cc1:PopupControlExtender ID="PopupControlExtender3" runat="server" TargetControlID="txt_combo_location"
                               PopupControlID="Panel_location" Position="Bottom">
                           </cc1:PopupControlExtender>
                           <input type="hidden" name="hide_location" id="hide_location" runat="server" />
                           <asp:Panel ID="Panel_location" runat="server" Width="450" Height="200px" ScrollBars="Vertical"
                               BackColor="AliceBlue" BorderColor="Gray" BorderWidth="1">
                               <asp:CheckBoxList ID="chk_location" CssClass="radio_button_txt" runat="server" Width="450"
                                   onclick="Checklocation(this)">
                               </asp:CheckBoxList>
                           </asp:Panel>
                       </div>






thanks in advance
Posted

1 solution

where is txt_combo_international_location ?

I advise that you check the aspx code after iis analysed and show it to us .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900