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 September 12th, 2007, 11:11 AM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Request action on change and get no action. Help

I have a problem. I am creating a form on this form there is a need for two autocomplete controls. The first control is the state this is done using scriptaculous and is working fine. The next is city the list of cities is of course dependent on the state. I have tried several variations but I can't get the first control to fire a change event. I have tried many variations but I will include only two here so you can get a feel of what I have tried.

Attempt 1:
I have tried several variations on this theme, set up a listener, use the prototype observe, etc
Code:
var txtState =
{
    var StateElement;

    init:
    {
        StateElement = Document.getElementById("txtState");
        StateElement.onchange = StateChangeHandler();
    }


}

//Handle the change event for the state text box
function stateChangeHandler()
{
/****************I Can't get here************/
    //Set up Ajax Request Object
    try //Normal Browsers
    {
        var requester = new XMLHTTPRequest();
    }
    catch(error)
    {
        try //Microsoft Browsers
        {
            var requester = nex ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(error)//Browser can not use Ajax
        {
            var requester = null;
        }
    }

Attempt 2:
After a while I thought that maybe I could use scriptaculous options this is my current run down that line.
Code:
var stateText =
{


    init:
    {

    //Here I took this declaration out of the HTML cleaner this way
        var stateCompleter = new Ajax.Autocompleter("txtState", "state_complete", "PScripts/autoCompleteStateHandler.php", {afterUpdateElement:stateChangeHandler()});

        stateChangeHandler);
    }


}

//Handle the change event for the state text box
function stateChangeHandler(input,item)
{/******************************* Still Can't get here ***************************/
    //Set up Ajax Request Object
   new Ajax.Request(
      "PScripts/list_cities.state="+input), //$F will get the value in the txtState control
      {
        method:"get",
        onComplete:function(xhr){
        citiesXML=xhr.response.xml;
        setCity(citiesXML);
      }
}


function setCity(cityData)
{
    cityArray = $A(cityData);
}

Core.start("stateText");// This is just an window onload listner





Similar Threads
Thread Thread Starter Forum Replies Last Post
action script sanjay_yadavhhh4 ActionScript 0 October 22nd, 2008 12:07 AM
Change form ACTION value from checkbox value Nazz Javascript 3 March 10th, 2005 11:50 AM
Two action in a form johnjohn Classic ASP Components 1 November 16th, 2004 05:45 PM
I want button action to change current window drb2k2 JSP Basics 0 June 4th, 2003 06:00 AM





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