Connecting Tech Pros Worldwide Forums | Help | Site Map

how can I used javascript for chaging values in TextBox

Anton ml. Vahčič
Guest
 
Posts: n/a
#1: Nov 18 '05
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.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 30.1.2004


Janaka
Guest
 
Posts: n/a
#2: Nov 18 '05

re: how can I used javascript for chaging values in TextBox


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;

"Anton ml. Vahčič" <anton.vahcic@campus.fri.uni-lj.si> wrote in message news:uR3sz2x6DHA.1504@TK2MSFTNGP12.phx.gbl...
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.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 30.1.2004

bruce barker
Guest
 
Posts: n/a
#3: Nov 18 '05

re: how can I used javascript for chaging values in TextBox


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)

"Janaka" <janaka@magicalia.com> wrote in message news:uu$fPpy6DHA.2540@TK2MSFTNGP11.phx.gbl...
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;

"Anton ml. Vahčič" <anton.vahcic@campus.fri.uni-lj.si> wrote in message news:uR3sz2x6DHA.1504@TK2MSFTNGP12.phx.gbl...
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.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 30.1.2004

Closed Thread