473,396 Members | 1,884 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,396 software developers and data experts.

check box enable/disable

i want to enable one listbox and disable the other depending on if i
check winter_gala (checkbox)

here is my code.
<script type="text/javascript">
function check()
{
if (document.forms.winter_gala.checked=true)
{
document.forms.winter_gala.young_friend_list.disab led=true
document.forms.winter_gala.dual_young_friend_list. disabled=false
}
else if (document.forms.winter_gala.checked=false)
{
document.forms.winter_gala.young_friend_list.disab led=false
document.forms.winter_gala.dual_young_friend_list. disabled=true
}
}
</script>

Jul 23 '05 #1
1 3719
wrote on 27 dec 2004 in comp.lang.javascript:
i want to enable one listbox and disable the other depending on if i
check winter_gala (checkbox)

here is my code.
<script type="text/javascript">
function check()
{
if (document.forms.winter_gala.checked=true)
{
document.forms.winter_gala.young_friend_list.disab led=true
document.forms.winter_gala.dual_young_friend_list. disabled=false
}
else if (document.forms.winter_gala.checked=false)
{
document.forms.winter_gala.young_friend_list.disab led=false
document.forms.winter_gala.dual_young_friend_list. disabled=true
}
}
</script>
I fail to read a question in your posting.
Doesn't it work? do you gat an error?
What error on what row?
;-)

========================
if (document.forms.winter_gala.checked=true)
[(document.forms.winter_gala.checked=true) SETS the value to true,
and always returns true]

should be ["==" is comparison, "=" is assignment]:

if (document.forms.winter_gala.checked == true)

but testing a boolean value against true is superfluous, so:
if (document.forms.winter_gala.checked)
========================
else if (document.forms.winter_gala.checked=false)


this is [after correcting to "=="] the same as simply:

else

========================

I fail to see how

forms.winter_gala

can be both a checkable element and the parent of

young_friend_list

Correct for that!

========================

then try:
<script type="text/javascript">
function check() {
var temp = document.forms.winter_gala //see objection
var temp1 = temp.young_friend_list
var temp2 = temp.dual_young_friend_list
if (temp.checked) {
temp1.disabled = true
temp2.disabled = false
} else {
temp1.disabled = false
temp2.disabled = true
}
}
</script>

===========================

or even shorter and IMHO more clear:

<script type="text/javascript">
function check() {
var temp = document.forms.winter_gala //see objection
var temp1 = temp.young_friend_list
var temp2 = temp.dual_young_friend_list

temp1.disabled = temp.checked
temp2.disabled = !temp.checked
}
</script>

Not tested, since no HTML.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2

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

Similar topics

1
by: vncntj | last post by:
i want to enable one listbox and disable the other depending on if i check winter_gala (checkbox) here is my code. <script type="text/javascript"> function check() { if...
2
by: eddie wang | last post by:
Hello, I inherited an Access application from a previous coworker. It seems the Spell Check is never enabled unless I open the application by holding down the shift key and double clicking the...
3
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76)...
0
by: talal | last post by:
How to check whether javascript is enable or disable in client browser. Remeber i can check wheter browser client support javascript with BrowserCapability class. But what if the client has disable...
10
by: Just Me | last post by:
If I periodically check to see if the floppy is ready, the drive will each time make a little noise. I've been up against this before and could never find a way to check to see if the floppy...
4
by: John Salerno | last post by:
My code is below. The main focus would be on the OnStart method. I want to make sure that a positive integer is entered in the input box. At first I tried an if/else clause, then switched to...
8
by: rongchaua | last post by:
Hi all, i would like now to disable and enable network adapter programmatically with c#. I have searched but found nothing useful. There's no topic about this problem. Has someone done with this...
3
by: Pietro | last post by:
Hi all, First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm...
3
by: thirish | last post by:
Hi, I have jsp page, on jsp page, The data is displaying from xml island. the Requriement is i have optional button and dropdown in each row. if user check the option button in second row then...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.