Click here to Skip to main content
14,387,606 members
Rate this:
Please Sign up or sign in to 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: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 22: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
Rate this:
Please Sign up or sign in to vote.

Solution 1

function filladult(nopersons)
    {

    alert("you are here :" + nopersons);
     document.getElementById(<%=txtadult.ClientID%>).value= nopersons;
    }
   
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?
Rate this:
Please Sign up or sign in to vote.

Solution 2

function filladult(nopersons)
    {

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


or

function filladult(nopersons)
    {

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


Make sure you have included the js.min to your page for "$".
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100