Click here to Skip to main content
12,451,227 members (52,308 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET Javascript HTML
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 21-Dec-12 21:09pm
Updated 21-Dec-12 21:26pm
v2
Comments
Krunal Rohit 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: bad
 
good
Please Sign up or sign in to vote.

Solution 1

function filladult(nopersons)
    {
 
    alert("you are here :" + nopersons);
     document.getElementById(<%=txtadult.ClientID%>).value= nopersons;
    }
  Permalink  
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: bad
 
good
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 "$".
  Permalink  

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


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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