Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old January 27th, 2005, 11:27 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Using a checkbox to enable SELECT field?

Hi!
In my lack of javascript knowlengde, i have to ask...

How can i get a select box to be disabled by default, and enabled when i hit the checkbox?

Ive got this.. (found it at this board)

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
<!--
function disableText()
{
document.form1.expired.disabled=true;
return;
}
-->
</script>
</head>
<body>
<form name="form1">
<p>
<input type="checkbox" name="checkbox" value="checkbox" onFocus="return disableText();">
</p>
<p>
<SELECT NAME="expired">
<OPTION SELECTED VALUE="01">jan
<OPTION VALUE="02">feb
<OPTION VALUE="03">mar
</SELECT>&nbsp;
</form>
</p>

<p><li>When page loads, the select boxes are disabled by default?</p>
<p><li>When you hit the checkbox, you enable the selectboxes?</p>
<p><li>When you hit the checkbox again, the selectboxes are disabled?</p>

</body>
</html>

Reply With Quote
  #2  
Old January 27th, 2005, 02:01 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Using a checkbox to enable SELECT field?

Here is the modified code to do what you want.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
<!--
function disableText()
{
if(document.form1.checkbox.checked){
document.form1.expired.disabled=false;
}else{
document.form1.expired.disabled=true;
}
}
-->
</script>
</head>
<body>
<form name="form1">
<p>
<input type="checkbox" name="checkbox" value="checkbox" onclick="disableText();">
</p>
<p>
<SELECT NAME="expired" disabled>
<OPTION SELECTED VALUE="01">jan
<OPTION VALUE="02">feb
<OPTION VALUE="03">mar
</SELECT>&nbsp;
</form>
</p>

<p><li>When page loads, the select boxes are disabled by default?</p>
<p><li>When you hit the checkbox, you enable the selectboxes?</p>
<p><li>When you hit the checkbox again, the selectboxes are disabled?</p>

</body>
</html>

Reply With Quote
  #3  
Old January 27th, 2005, 03:11 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Using a checkbox to enable SELECT field?

Thank you!! Wow! Great!!


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Using a checkbox to enable SELECT field?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT