DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Posts
    1

    OnChange Code Not Working With Multiple Forms

    I am completely new to AJAX, so I got this code from another site and installed it for what I need. It works great if I have only one form on the page ... however, once I have multiple forms on the page, it stops working but it doesnt throw an error code, so I have no clue where to look. Any help would be appreciated!

    Select Field Code:
    Code:
    onChange="showField(this.value, 'QQTrim')"
    Ajax.js:
    Code:
    function GetXmlHttpObject() {
    	var xmlHttp=null;
    	try {
    		xmlHttp=new XMLHttpRequest();
    	}
    		catch (e) {
    			try {
    				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    			}
    		catch (e) {
    			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	}
    	return xmlHttp;
    }
    
    function showField(str, id){
    	var url="inc/ajaxforms.php"
    	url=url+"?modField="+id
    	url=url+"&modString1="+str
    	url=url+"&sid="+Math.random()
    	xmlHttp=GetXmlHttpObject();
    	xmlHttp.onreadystatechange= function() {
            if (xmlHttp.readyState==4)
                if (xmlHttp.status==200)
                    writeHTML(xmlHttp, id);
        }
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);	
    }
    
    function writeHTML(req, id) {
        document.getElementById(id).innerHTML = req.responseText;
    }

  2. #2
    Join Date
    Mar 2007
    Location
    In the Matrix
    Posts
    3
    Have you checked to make sure they are not using the same id?
    Last edited by WebGeek182; 03-14-2007 at 07:25 PM.

Similar Threads

  1. Problem with multiple forms
    By partyk1d24 in forum ASP.NET
    Replies: 0
    Last Post: 04-06-2006, 09:47 AM
  2. Replies: 1
    Last Post: 08-23-2005, 01:15 PM
  3. Replies: 0
    Last Post: 04-11-2002, 06:48 PM
  4. Replies: 90
    Last Post: 04-17-2001, 12:45 AM
  5. VB Forms Calling C++ Code
    By Lawrence Brabham in forum authorevents.morrison
    Replies: 1
    Last Post: 11-13-2000, 10:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links