473,414 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Set ReadOnly Property With CheckBox Value

I want to set a textbox's ReadOnly value to the OPPOSITE value that the
CheckBox has. For example: If the user checks the CheckBox then the
ReadOnly property for the TextBox is set to False. The default value of
the TextBox is set to false. Am I on the right path or am I totally
off in left field?
<input type="checkbox" name="chkCode1" value="ON"
onclick="document.DisplayCodes.txtGrossPayroll1.re adOnly !=
document.DisplayCodes.chkCode1">
<br>
<input type="text" style="text-align: right;" size="10" tabindex='1'
readonly="true" name="txtGrossPayroll1" value="0" width="10"
onkeyup="ComputePremium(1)" onkeypress="return blockNumbers(event)"/>
Thanks,
CR Junk

Jul 23 '05 #1
4 15703
I've gotten a little closer, but no completely. Instead of using the
ReadOnly property I tried the Disabled property. When I put a check in
the checkbox, the disabled property is set to false, but if I uncheck
the checkbox, the textbox is not disabled. Can someone tell me what
I'm missing?

<input type="checkbox" name="chkCode1" value="ON"
onclick="document.DisplayCodes.txtGrossPayroll1.di sabled=
!document.DisplayCodes.chkCode1" />
<br>
<input type='text' style='text-align: right;' size='10' tabindex='1'
disabled='true' name='txtGrossPayroll1' value='0' width='10'
onkeyup='ComputePremium(1)' onkeypress='return blockNumbers(event)'/>

Thanks,
CR Junk

Jul 23 '05 #2
ASM
crjunk wrote:
I want to set a textbox's ReadOnly value to the OPPOSITE value that the
CheckBox has. For example: If the user checks the CheckBox then the
ReadOnly property for the TextBox is set to False. The default value of
the TextBox is set to false. Am I on the right path or am I totally
off in left field?


<input type="checkbox" name="chkCode1" value="ON"
onclick="txtGrossPayroll1.disabled = (this.checked);">
<br>
<input type="text" style="text-align: right;" size="10" tabindex='1'
readonly="true" name="txtGrossPayroll1" value="0" width="10"
onkeyup="ComputePremium(1)" onkeypress="return blockNumbers(event)" />
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #3

Well:
<input type="checkbox"
onmouseup="this.form.txtGrossPayroll1.readOnly!=th is.checked" />
<input type="text" style="text-align: right;" size="10" tabindex='1'
readonly="true" name="txtGrossPayroll1" value="0" width="10"
onkeyup="ComputePremium(1)" onkeypress="return blockNumbers(event)"/>

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #4
Thanks for everyone's help. I was able to get it to work correctly by
referring ot ASM's example.

I came up with:
onclick="document.DisplayCodes.txtGrossPayroll1.di sabled =
!(this.checked);"

Thanks again!

CR Junk

Jul 23 '05 #5

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

Similar topics

1
by: Jack | last post by:
Hi, I have a asp page where a checkbox, when clicked will disable all text boxes associated with the page. The following is a part of a code for the checkbox with its name and readonly...
5
by: Randell D. | last post by:
Folks, I have a few <INPUT TYPE=TEXT> tags that are readonly if a specific field has no value... these work fine. However, I also have checkboxes which I would like to have as readonly, but the...
0
by: andrei | last post by:
Hi Group, I have a checkbox column in a web datagrid which is related to a "Product in stock" property. The grid is in view mode, so the user can't (and shouldn't) change anything in the grid....
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
4
by: Dany P. Wu | last post by:
Hi everyone, I'm not entirely sure if this is the best way of going about it, but here's the scenario.......... I have two datagrid, each bound to a datatable which have checkbox columns....
0
by: johnb41 | last post by:
I have a datagrid that has it's first column set to a checkbox column. I need that column to be "checkable", while all the others not editable. So I created columnstyles First I add a boolean...
2
by: miben | last post by:
I need to set a variable returned by a readonly property in a class by another class. So the only way to set that value is from a specific class and function. Public Sub Main Dim setter As New...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
How can I make a checkbox control ReadOnly - can't check or uncheck without having to set the Enabled Property to False? VB2005 I looked at the property sheet for the Checkbox control but did...
0
by: Tom Dacon | last post by:
Oops, what I gave you in my first response was the usual way that you use varying scope: Private _FieldValue As <some type> Public Property Something As <some type> Get Return _FieldValue...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.