473,509 Members | 2,918 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java script enabled textbox

GMK
dear all
i'm building an asp.net application i have on one of my pages a checkbox i
want that whenever the user checkd the checkbox to enable a textbox and when
the user uncheck the checkbox the textbox will be diabled.
i want to make those action on client side.
so if anyone could provide me the code i would be so thankful
thank you
Nov 19 '05 #1
4 4335
Something like this:

<input type="checkbox" id="x" onClick="ToggleInput(this, 'username');" >
<input type="text" id="username" >

<script language="javascript">
function ToggleInput(check, txtBox){
var txt = document.getElementById(txtBox);
txt.disabled = !(check.checked);
}
</script>

??

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"GMK" <x@x.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
dear all
i'm building an asp.net application i have on one of my pages a checkbox i
want that whenever the user checkd the checkbox to enable a textbox and when the user uncheck the checkbox the textbox will be diabled.
i want to make those action on client side.
so if anyone could provide me the code i would be so thankful
thank you

Nov 19 '05 #2
GMK
I tried this peace of code it worked correctly with an asp file but when i
tried to use it in an aspx page it gave me a JScript rintime error.
i'm using asp.net 1.1
does all javasscript syntax compatible with asp.net 1.1
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:#K**************@tk2msftngp13.phx.gbl...
Something like this:

<input type="checkbox" id="x" onClick="ToggleInput(this, 'username');" >
<input type="text" id="username" >

<script language="javascript">
function ToggleInput(check, txtBox){
var txt = document.getElementById(txtBox);
txt.disabled = !(check.checked);
}
</script>

??

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"GMK" <x@x.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
dear all
i'm building an asp.net application i have on one of my pages a checkbox i want that whenever the user checkd the checkbox to enable a textbox and

when
the user uncheck the checkbox the textbox will be diabled.
i want to make those action on client side.
so if anyone could provide me the code i would be so thankful
thank you


Nov 19 '05 #3
Hi GMK,

do the following
Add the OnClick event OnClick="ToggleTextbox();"

e.g

<asp:CheckBox id="CheckBox1" OnClick="ToggleTextbox();" runat="server"
</asp:CheckBox>

and then in the script tag

<script>
function ToggleTextbox()
{
if (document.Form1.CheckBox1.checked == true)
document.Form1.TextBox1.disabled = false;
else
document.Form1.TextBox1.disabled = true;
}
</script>
considering that the Id of textbox that you want to disable is TextBox1

***********************************
Hope this helps
Shaun (M.C.P)

http://blogs.wwwcoder.com/shaunakp
***********************************

"GMK" wrote:
dear all
i'm building an asp.net application i have on one of my pages a checkbox i
want that whenever the user checkd the checkbox to enable a textbox and when
the user uncheck the checkbox the textbox will be diabled.
i want to make those action on client side.
so if anyone could provide me the code i would be so thankful
thank you

Nov 19 '05 #4
check mine ! i have used it in a ASPX page
********************************
Hope this helps,
Shaun (M.C.P)

http://blogs.wwwcoder.com/shaunakp
*********************************

"GMK" wrote:
I tried this peace of code it worked correctly with an asp file but when i
tried to use it in an aspx page it gave me a JScript rintime error.
i'm using asp.net 1.1
does all javasscript syntax compatible with asp.net 1.1
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:#K**************@tk2msftngp13.phx.gbl...
Something like this:

<input type="checkbox" id="x" onClick="ToggleInput(this, 'username');" >
<input type="text" id="username" >

<script language="javascript">
function ToggleInput(check, txtBox){
var txt = document.getElementById(txtBox);
txt.disabled = !(check.checked);
}
</script>

??

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"GMK" <x@x.com> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
dear all
i'm building an asp.net application i have on one of my pages a checkbox i want that whenever the user checkd the checkbox to enable a textbox and

when
the user uncheck the checkbox the textbox will be diabled.
i want to make those action on client side.
so if anyone could provide me the code i would be so thankful
thank you



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
24722
by: Steven Green | last post by:
I have a java app at work I used when I had Windows 98 and never had a problem. I did a clean install of Windows XP and of course Java was not included. I went to Sun, download Java 2 Runtime...
3
2359
by: Alexander Fillips | last post by:
Hi, my short question: is there a python object which can interpret java-script? the whole story ;-) I wrote some streaming-scripts for the xbox mediaplayer which supports python. for a...
8
7382
by: Sergei | last post by:
Hi, I am displaying modal dialog and passing values from the main form to the modal dialog and back. It works fine but if I used the following syntax on Page_Load(just for testing) in VB to...
9
3285
by: Stephen H. | last post by:
Hi, I have an existing web application with java beans that I wanne migrate to ASP.NET using C#. The existing web application has some jsp files that use java beans as follows: .... <%@...
7
1955
by: dbabin | last post by:
I have a java script function enableServerList() {document.getElementById("ddlServers").disabled=false } function disableServerList() {document.getElementById("ddlServers").disabled=true } ...
5
1993
by: Bjorn Sagbakken | last post by:
Hello I have just migrated from VS 2003 to VS 2005, and .NET framework 1.1 to 2.0 I am at the end of debugging and fixing stuff. Now there is one error I just cannot find a solution to: On...
2
8175
by: aussie1968 | last post by:
hi, i need to be able to find out when the user changes a date, which is displayed in a textbox using a CalendarExtender. because the CalendarExtender only allows client side (java) calls and...
2
3952
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
1
2660
by: anilkumar1980 | last post by:
Hi All, Here I need help to all of u, I am using ASP.NET 2.0 and Third party Infragistic Controls. I Have included master page in my page (<%@ Page Language="VB"...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.