AJAX Question

    Date: 04/06/07 (Web Development)    Keywords: php, browser, html, xml, microsoft

    I have a form of potentially 8 select menus, the goal of which is when you change the value it calculates a new cost based on the choices made. In order to bypass the annoying IFRAME issue of ruining your browser back button I'm looking into alternative scripting options - and while I am woefully unfamiliar with AJAX it seems to be my best option.

    I've got a script 'working' - processing one option, but I cannot seem to see how to get it to support multiple options. All it really needs to do is parse the options into a string for PHP like foo.php?item1=THIS&item2=THAT.

    The script I'm using now looks like this:

    var AJAXForms = false;
    var LastField = null;
    var isIE = false;
    
    if (window.XMLHttpRequest) {
      AJAXForms = new XMLHttpRequest();
    }
    
    function CheckField(field) {
    
      if (window.XMLHttpRequest) {
      } else if (window.ActiveXObject) {
        AJAXForms = new ActiveXObject("Microsoft.XMLHTTP");
      }
    
      AJAXForms.onreadystatechange = processChange;
      AJAXForms.open("GET", "check.php?&quantity="+field.value);
      LastField = field.name;
      AJAXForms.send(null);
    }
    
    function processChange() {
      if (AJAXForms.readyState == 4) { 
        var res = document.getElementById(LastField);
        res.innerHTML = AJAXForms.responseText;
        res.style.visibility = "visible";
      }
    }


    With HTML of 'OnChange="CheckField(this)"' attached to the dropdown. So what I'd like to do is either a.) Get this script to support up to 8 variables or b.) Get some direction on examples / tutorials in order to write one myself. Any help would be much appreciated.

    Source: http://community.livejournal.com/webdev/400638.html

« Images in a database || Website Design »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home