I've posted this in at least 6 other forums with no responses. 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: - onChange="showField(this.value, 'QQTrim')"
Ajax.js: - 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;
-
}
9 2217
Welcome to TSDN (The Scripts).
Do all your forms have the same id?
Show your form code.
I've posted this in at least 6 other forums with no responses. 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: - onChange="showField(this.value, 'QQTrim')"
Ajax.js: - 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;
-
}
================
I could not find anything wrong with your code.
But I assume you may have used same elements 'id' for all the element.
An element id must be unique throughout the document.
The ID is only used once throughout the entire page ... that was the first thing that I checked ...
I checked the page. The Ajax function is definitely being called, but it is failing. You can change your code to check the status.
I know this sounds daft, but since it is in a new directory, are you sure you have inc/ajaxforms.php in your jeep/new directory - in other words, does the file exist?
/jeep/new is actually redone by apache (.htaccess) to point to index.php?module=new. Everything on the site is driven by one page ... so it shouldnt be a problem or could I be wrong?
Thanks for the enlightenment! In the AJAX.js file, I changed the following:
var url="inc/ajaxforms.php"
url=url+"?modField="+id
url=url+"&modString1="+str
url=url+"&sid="+Math.random()
to:
var url="/inc/ajaxforms.php"
url=url+"?modField="+id
url=url+"&modString1="+str
url=url+"&sid="+Math.random()
Even though everything is generated off of one page, I guess because I am "faking" the directory structure, the "/" at the beginning was needed! Thanks for pointing that out for me!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: please-answer-here |
last post by:
Scenario:
I'm having an asp page with a form with an action pointing to itself. The
reason for that, it that the asp page depending on changes in any of two
select fields with data from 2...
|
by: Mattias Campe |
last post by:
Hello,
On http://student.ugent.be/astrid/bewoners.php I got the problem that I
want Javascript to let my browser go to
http://student.ugent.be/astrid/bewoners.php?beginAcjaar=2002 when I
select...
|
by: Bart van Deenen |
last post by:
Hi all
I have a script where I dynamically create multiple inputs and selects
from a script. The inputs and selects must have an associated onchange
handler.
I have the script working fine on...
|
by: doc |
last post by:
Hi,
<SCRIPT LANGUAGE="JavaScript">
function check_selection(selection){
document.pr.n_o.checked=true;
}
</SCRIPT>
<form name=pr action=test.php method=post>
|
by: Pascal Batzli Jr |
last post by:
Hello,
I have a strange situation happening on the code below. When I first
load the page, as I change any of the three combo boxes I have created,
the onchange event is fired and the form should...
|
by: Craig831 |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms...
|
by: jab3 |
last post by:
Hello. I"m new to this group, and to JavaScript in general, so please
forgive me if I breach local etiquette. I'm trying to implement some
client-side 'dynamic' validation on a form. I'm having...
|
by: auslandt |
last post by:
I have an HTML file that includes a JavaScript. I would like this JavaScript to be able to create an "onChange=<function>" attribute against the password element.
Here is an example page of the...
|
by: colyn7 |
last post by:
I really can't see what's wrong in my code... the submit() onChange doesn't work..
I've tried..
<select name="ddlTestCenter" id="ddlTestCenter" style="width:180px"...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |