473,382 Members | 1,447 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,382 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 3717
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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...

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.