Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
|
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2008, 06:15 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ajax change textbox bgcolor after Criteria met

I have created this script:

<script type="text/javascript">
function showHint(str)
{
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="Scripts/ASP/CheckNewUsername.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}


function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("InputSource").style.backg roundcolor='red';
VarResult = xmlHttp.responseText;
document.getElementById("txtHint").innerHTML=VarRe sult;
 }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
  </script>

---------


The script goes to an asp page checks a database to see if the email address entered into a text box is correct and then the java displays a message. This works fine but i want the Email Address text box to change to a red background color to show its an error and it doesnt want to do it:

document.getElementById("InputSource").style.backg roundcolor='red';


Im sure it must be something simple
 
Old July 28th, 2008, 08:56 AM
Authorized User
 
Join Date: Jul 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like backgroundColor should have the capital C in it.

Shawn Steward
Web Developer
www.shawnsteward.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change all cells in a row via AJAX MartinNr5 Javascript How-To 1 January 9th, 2007 08:53 AM
change bgColor crmpicco Javascript 1 July 9th, 2005 07:29 PM
Using a textbox as query criteria problem marcin2k Access VBA 5 March 30th, 2005 12:01 PM
Query: getting criteria from a textbox in a form lguzman Access VBA 2 November 1st, 2004 10:16 AM
onClick change bgcolor of entire row Pallav Javascript How-To 2 October 21st, 2004 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.