how can I used javascript for chaging values in TextBox

  • Thread starter Thread starter =?iso-8859-2?Q?Anton_ml._Vah=E8i=E8?=
  • Start date Start date
?

=?iso-8859-2?Q?Anton_ml._Vah=E8i=E8?=

Hi,

I have a typical textBox:
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 24px" runat="server">test</asp:TextBox>
</form>

How can I use javascript to change value of TextBox from test to something else for example "test1".

Thanks,
Anton, ml.
 
First of all does this need to be done on the client side? If its something that can be done on postback then using TextBox1.Text = "test1" will suffice.
If it has to be done through javascript I've found the trick is to add the attribute name="TextBox1" to your control, because Javascript won't understand ID. then you can reference the control's text value through document.forms[0].elements['TextBox1'].value;

Hi,

I have a typical textBox:
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 24px" runat="server">test</asp:TextBox>
</form>

How can I use javascript to change value of TextBox from test to something else for example "test1".

Thanks,
Anton, ml.
 
actually you can use the W3C standard routines with most browsers to access the control by ID.

document.getElementById('<%=TextBox1.UniqueID%>').value = 'new text value';

-- bruce (sqlwork.com)

First of all does this need to be done on the client side? If its something that can be done on postback then using TextBox1.Text = "test1" will suffice.
If it has to be done through javascript I've found the trick is to add the attribute name="TextBox1" to your control, because Javascript won't understand ID. then you can reference the control's text value through document.forms[0].elements['TextBox1'].value;

Hi,

I have a typical textBox:
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 24px" runat="server">test</asp:TextBox>
</form>

How can I use javascript to change value of TextBox from test to something else for example "test1".

Thanks,
Anton, ml.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top