Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I need to fill the txtadult field at onchange of txtnoofpersons. The jscript is running fine but txtadult is not shown in the
form. the jscript and the html code is given below for reference. Kindly tell me what is going worng
function filladult(nopersons)
    {

    alert("you are here :" + nopersons);

     document.getElementById('txtadult').value= nopersons;
    }

ASP
-----------
<asp:TextBox ID="txtnoofperson" runat="server" BorderColor="LightGray" BorderStyle="Solid"
                                                                                                            BorderWidth="1px" CssClass="tabForm" Width="50px" OnFocus="this.style.backgroundColor='#F9FEE0',this.style.borderColor='#000000'"
                                                                                                            OnBlur="this.style.backgroundColor='',this.style.borderColor=''"
                                                                                                            OnTextChanged="txtnoperson" onchange ="filladult(this.value)"> </asp:TextBox>
                                                                                                        <cc1:FilteredTextBoxExtender ID="txtnoofperson_FilteredTextBoxExtender" runat="server"
                                                                                                            Enabled="True" FilterType="Numbers" TargetControlID="txtnoofperson">
                                                                                                        </cc1:FilteredTextBoxExtender>
-------
<asp:TextBox ID="txtadult" runat="server"  BorderColor="LightGray"
                                                                                                            BorderStyle="Solid" BorderWidth="1px" CssClass="tabForm" Width="50px" OnFocus="this.style.backgroundColor='#F9FEE0',this.style.borderColor='#000000'"
                                                                                                            OnBlur="this.style.backgroundColor='',this.style.borderColor=''"
                                                                                                            Enabled="False"></asp:TextBox>
Posted
Updated 21-Dec-12 21:26pm
v2
Comments
[no name] 22-Dec-12 3:32am    
try to put alert('') and check whether your JS is really working or not..
Subha Ranjan Saha 22-Dec-12 3:51am    
alert is already given and it is showing the value but in the web page the value is not shown

C#
function filladult(nopersons)
    {

    alert("you are here :" + nopersons);
     document.getElementById(<%=txtadult.ClientID%>).value= nopersons;
    }
 
Share this answer
 
Comments
Subha Ranjan Saha 22-Dec-12 3:58am    
Still not working with this code
AshishChaudha 22-Dec-12 5:07am    
Is there contentPlaceholeder in your page?
XML
function filladult(nopersons)
    {

    alert("you are here :" + nopersons);
     document.getElementById(<%= txtadult.ClientID %>).value= nopersons;
    }


or

XML
function filladult(nopersons)
    {

    alert("you are here :" + nopersons);
     $("#txtadult").val()= nopersons;
    }


Make sure you have included the js.min to your page for "$".
 
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