Javascript Function querying SQL Recordset in ASP page

I have an asp page with some input boxes. I have an onchange function that is fired on change of the value in the input box. What I want the function to do is take the new value entered in the text box and query it to see if it is in a SQL server table if it is not produce and error message.
cyberdidjAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cLFlaVACommented:
This cannot be achieved with JavaScript; you'll have to have the form submit itself when the onchange event occurs, so that your ASP can query the database to check the value.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sigmaconCommented:
For IE 5.5+, Mozilla-based browsers using 1.3 or higher (e.g. Firefox 0.8+) and Safari 1.3+:

instantiate an XML Request Object:

      try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
            try {
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                  try {
                        xmlhttp = new XMLHttpRequest();
                  } catch (eE) {
                        alert("Could not create XMLHttpRequest object!\nPlease use a browser that supports this feature.");
                        throw "Could not create XMLHttpRequest object!\nPlease use a browser that supports this feature.";
                  }
            }
      }

if xmlhttp is not null or undefined, you can continue.

get the value from the drop down ( I am assuming you know how to do that), then make a request to your server where you have a file that runs the actual query:

    try {
      xmlhttp.open("GET", "checkvalue.asp?random=" + rand(100000000) + "&valuetocheck=" + valuetocheck, false);
        xmlhttp.send(null);
      if (xmlhttp.responseText == 'value_is_valid') {
            // do something
      } else {
            // show error message
      }
    } catch (e) {
        debugException(e);
    }

this special asp page should not return any html, but text that you can use to determine whether the value was valid or not. The beaty of this is that it does not require a new page reload. The downside is it only works with the latest browsers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.