JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 25th, 2003, 09:01 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
testing for field disabled = true or false

I tryed to make a snippet that would allow to me to set a text field to disabled if a checkbox was clicked,...and re-enable it if the same checkbox was clicked again. am I on the right track here?

Code:
<script type="text/javascript" language="javascript">
<!--
	function checkFieldStatus( theForm, theElement )
	{
		if( theForm.theElement.disabled = true )
		{
			setFieldEnabled( theForm, theElement );
		}
		
		if( theForm.theElement.disabled = false )
		{
			setFieldDisabled( theForm, theElement );
		}
	}
	
	function setFieldDisabled( theForm, theElement )
	{
		theForm.theElement.disabled = true;
		theForm.theElement.onfocus = theForm.theElement.blur;
	}
	
	function setFieldEnabled( theForm, theElement )
	{
		theForm.theElement.disabled = false;
		theForm.theElement.onfocus = null;
	}

// -->
</script>

Code:
onclick="checkFieldStatus( document.myForm, the_field_to_check )"
__________________
-- Jason

Reply With Quote
  #2  
Old July 7th, 2003, 06:27 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 6
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
This being a lot simpler might just help you out:
PHP Code:
<html>
<
head>
<
title>Test</title>
<
script type="text/javascript" language="javascript">
<!--
    function 
checkFieldStatustheElementstatus )
    {
    
theElement.disabled status;
    }

// -->
</script>
</head>
<body>
<form name="testform" method="post" action="">
    <input type="textbox" name="mytext">
    <input type="checkbox" name="mycheck" onclick="checkFieldStatus(document.forms.testform.mytext, this.checked);">
</form>
</body>
</html> 
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old July 7th, 2003, 08:53 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
very very nice..... me likes

Reply With Quote
  #4  
Old July 7th, 2003, 12:55 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Nice indeed.

Also, in case this was a mistake and not a typo, the conditions in your if statements used assignment operators rather than logical operators. I think this probably always evaluates to true (unless you have something like division by 0 on the right side of the operator). Make sure you use == rather than = if you're testing a condition.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > testing for field disabled = true or false


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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