Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-04-2008, 04:10 AM   PM User | #1
nikko50
Regular Coder

 
Join Date: May 2004
Posts: 375
Thanks: 62
Thanked 0 Times in 0 Posts
nikko50 is an unknown quantity at this point
Enable disabled checkbox via select list

Hi all. With the below test form I'm trying to enable the checkbox only when the user select the "CLOSED" option from the select box. Initially when the form loads the checkbox ihas a onClick=\"return false\" event. How can I do this??

Code:
<form method="POST" name="theForm" action="--WEBBOT-SELF--">
 
  <p><input type="checkbox" onClick="return false" name="TEST"></p>
  <p><select name="STATUS">
    <option value="ACTIVE">ACTIVE</option>
    <option value="CLOSED">CLOSED</option>
  </select></p>

  <p><input type="submit" value="Submit" name="B1"></p>
</form>

Last edited by nikko50; 09-04-2008 at 04:15 AM..
nikko50 is offline   Reply With Quote
Old 09-04-2008, 07:46 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,032
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Here you are, Tracy:-

Code:
<form method="POST" name="theForm" action="--WEBBOT-SELF--">
 
  <p><input type="checkbox" name="TEST" disabled></p>
  <p><select name="STATUS" onchange = "fixTest()">
    <option value="ACTIVE">ACTIVE</option>
    <option value="CLOSED">CLOSED</option>
  </select></p>

<p><input type="submit" value="Submit" name="B1"></p>
</form>

<script type = "text/javascript">
function fixTest() {
x = document.theForm.STATUS.value;
if (x == "CLOSED") {
document.theForm.TEST.disabled = false;
}
else {   // if user switches back to ACTIVE
document.theForm.TEST.checked= false;
document.theForm.TEST.disabled = true;
}
}
</script>
Did you receive the PM I sent you a while back?


A single parent would only be able to claim benefits for two years, and after those two years they would be literally pushed over the cliff - Politician

Last edited by Philip M; 09-04-2008 at 08:15 AM..
Philip M is offline   Reply With Quote
Old 09-04-2008, 01:42 PM   PM User | #3
nikko50
Regular Coder

 
Join Date: May 2004
Posts: 375
Thanks: 62
Thanked 0 Times in 0 Posts
nikko50 is an unknown quantity at this point
Works great and you remembered my name also!
nikko50 is offline   Reply With Quote
Old 09-04-2008, 03:55 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,032
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by nikko50 View Post
Works great and you remembered my name also!
Well, I do tend to remember the names of people who have a great many posts (all requesting assistance) but zero thanks.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 08:24 AM.


Advertisement
Log in to turn off these ads.