Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 30th, 2003, 11:06 PM
Authorized User
 
Join Date: Jun 2003
Location: Quezon City, NCR, Philippines.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vickriz
Default change background color of inputbox

hi again to all and good day.

is there anyone can help me how to code in javascript for changing the background color of inputbox.

let say i have 2 checkbox a YES and NO. if the user check NO. then my inputbox fields will change the background color so it will distinguish as disabled fields. can you give me some sample codes?

thanks in advance..




Mabuhay!!!
__________________
Mabuhay!!!
Reply With Quote
  #2 (permalink)  
Old July 1st, 2003, 04:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

The syntax you need to change the background colour is:
object.style.backgroundColor = New_Color

here's a simple example for you:
Code:
<html>
<head>
<script type="text/javascript" language="javascript">
function changeColour()
{
  if (document.frmSurvey.fld2.checked)
  {
    document.frmSurvey.fld1.style.backgroundColor="#FF0000"; // red
  }
  else
  {
    document.frmSurvey.fld1.style.backgroundColor="#FFFFFF"; // white
  }
}
</script>
</head>
<body>
<form name="frmSurvey" id="frmSurvey">
<input type="text" name="fld1" id="fld1"><br>
<input type="checkbox" name="fld2" id="fld2" onclick="changeColour()">change colour<br>
</body>
</html>
Reply With Quote
  #3 (permalink)  
Old July 1st, 2003, 10:36 AM
Authorized User
 
Join Date: Jun 2003
Location: Lexington, KY, USA.
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you want a standard color and you know its name, you can also use

....backgroundColor="red";

There are many named colors that will work.

-Van

-Van
(Old dog learning new tricks...)
Reply With Quote
  #4 (permalink)  
Old December 1st, 2009, 02:22 AM
Friend of Wrox
Points: 742, Level: 10
Points: 742, Level: 10 Points: 742, Level: 10 Points: 742, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Location: Tehran, Iran
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default use jQuery to build your own inputBox

--------------------------------------------------------------------------------

Hello,
You can perform it using jQuery. Are you familiar with jQuery?
It is a javascript library that enables you to any visual tasks like dragging windows, made any picture rounded, etc.
for example notice following:
$("div > p").css("background","#0C0C0C");
this means that change "background" propery of every "p" tag that is nested into a "div" tag, to "#0C0C0C".

I put some files in my blog for you. by these you can learn to perform what you wanted and other things.

http://aspnet35.brinkster.net/beetle...i-20090115.chm

http://aspnet35.brinkster.net/beetle...ery-1.2-v1.chm

http://aspnet35.brinkster.net/beetle_jaipur/jquery.js

http://aspnet35.brinkster.net/beetle...uery.corner.js

jquery.js in main javascript library. you can even get a link from Google servers.
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change background color using CSS pigtail Javascript How-To 9 April 4th, 2010 12:13 PM
change color of background meena88 C# 2005 3 December 1st, 2009 04:48 AM
Change the background color of a msgbox nobreferreira VB.NET 2002/2003 Basics 3 October 28th, 2004 10:37 AM
change background color of cell based on value vurtman ASP.NET 1.0 and 1.1 Basics 4 February 26th, 2004 03:52 PM



All times are GMT -4. The time now is 02:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.