hi i have trouble with disabled the select list when any of checkboxes is not checked and enable if one of them is checked this is my code - <script type="text/javascript">
-
<!--
-
function Select()
-
{
-
if (document.getElementById('one').checked )
-
{document.getElementById('class').disabled=false
-
}
-
if else (document.getElementById('two').checked )
-
{document.getElementById('class').disabled=false}
-
if else
-
{document.getElementById('class').disabled=true}
-
}
-
//-->
-
</script>
-
p> 2. Which our classes have you attended?<br/>
-
<input type="checkbox" name="classes" value="1" id="one" onclick="Select(this);" /> Aerobics</br>
-
<input type="checkbox" name="classes" value="2" id="two" onclick="select(this);" /> Boxing<br/>
-
<input type="checkbox" name="classes" value="3" id="three" onclick="select(this);" /> Circuit Class<br/>
-
<input type="checkbox" name="classes" value="4" id="four" onclick="select(this);" /> Weight Training </p>
-
-
<p> 3. Which of the above classes has been <b> most</b> beneficial for you?<br/>
-
(You can only choose one from list)
-
<select name="class" id="class" disabled="true" size="1" style="color:#FFFFFF; background-color:#8A2BE2">
-
<option value="Choose"> - -Please Choose- - </option>
-
<option value="AER">Aerobics</option>
-
<option value="Box">Boxing</option>
-
<option value="Circuit">Circuit Class</option>
-
<option value="Weight">Weight Training</option></select></p>
3 1015
Javascript is not java, you were in the wrong forum. And use code-tags around your code. And you are messing with lowercase-uppercase function names (Select() vs. select()). That's why it doesn't work. Javascript and Java are case sensitive. And you can't just revert "else if". If the syntax is wrong, then javascript doesn't work at all! (you can see a small error sign in the corner of your browser). This is incontrast to HTML, where you miss an opening bracket from your <p> tag and it still works, skipping the unreadable tag. Just enable your javascript debugger (e.g. firebug in firefox), it will tell you the lines that are wrong.
General tip: just edit a few lines only first and get it working with. Then add more. Add line, test, add line, test, and so on.
You can't just type a whole full-blown program without testing and then expect it to work immediately.
Dormilich 8,658
Recognized Expert Moderator Expert
swap "if" and "else" on lines 8 and 10 to get a valid if-elseif-else construct.
[edit] darn, missed by seconds ;)
you can also use "this" inside the function to simplify matters - function Select()
-
{
-
if (this.checked)
-
{
-
document.getElementById('class').disabled = false;
-
}
-
}
thanks alot its working now
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kai Grossjohann |
last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window.
That's fine, I don't need to do anything about it.
But Ctrl-N in IE appears to clone the current window. Is there a way
to intercept the key so that I can do stuff on the server side to make
the new window behave correctly?
(We have a JSP-based webapp which stores state in...
|
by: Cardman |
last post by:
Greetings,
I am trying to solve a problem that has been inflicting my self
created Order Forms for a long time, where the problem is that as I
cannot reproduce this error myself, then it is difficult to know what
is going on.
One of these Order Forms you can see here...
http://www.cardman.co.uk/orderform.php3
|
by: Alex Rast |
last post by:
First of all, this is not a programming question. I'm a user, not
programming in JavaScript. I'm not, however, a novice user or even a power
user - I certainly know programming intimately as well as computer
hardware, configuration, etc... down to the lowest level (e.g. BIOS,
assembly language, etc).
Anyway, I've obviously got something...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |