Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Set ReadOnly Property With CheckBox Value

Reply
Thread Tools

Set ReadOnly Property With CheckBox Value

 
 
crjunk
Guest
Posts: n/a
 
      07-21-2005
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

 
Reply With Quote
 
 
 
 
crjunk
Guest
Posts: n/a
 
      07-21-2005
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

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      07-21-2005
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
 
Reply With Quote
 
crjunk
Guest
Posts: n/a
 
      07-22-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox set to Readonly loses value Doogie ASP .Net 5 10-10-2012 12:13 AM
Set readonly property on cell level in a datagridview Patrik ASP .Net Building Controls 3 02-16-2007 01:30 AM
Programiticly Set Databound Readonly Property siamesedream@gmail.com ASP .Net 0 06-09-2006 02:09 PM
DataGrid: set ReadOnly property at runtime? John Smith ASP .Net 5 06-06-2006 03:30 PM
ASP.NET Readonly panel function with readonly checkbox, readonly radiobutton Jonathan Hyatt ASP .Net Web Controls 1 06-08-2004 07:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57