
Signature
Martin Honnen
http://JavaScript.FAQTs.com/
Full Java below:
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function createQueryString() {
var Brand = document.getElementById("Brand").value;
var queryString = "brand=" + Brand;
return queryString;
}
function doRequestUsingGET() {
createXMLHttpRequest();
var queryString = "response.php?";
queryString = queryString + createQueryString() ;
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("Post", queryString, true);
xmlHttp.send(null);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
document.getElementById("serverResponse").innerHTML =
xmlHttp.responseText;
}
}
}
function createQueryString2() {
var Brand = document.getElementById("Brand").value;
var Size = document.getElementById("size").value;
var queryString = "brand=" + Brand + "&size=" + Size;
return queryString;
}
function doRequestUsingGET2() {
createXMLHttpRequest();
var queryString = "listing.php?";
queryString = queryString + createQueryString2() ;
xmlHttp.onreadystatechange = handleStateChange2;
xmlHttp.open("Post", queryString, true);
xmlHttp.send(null);
}
function handleStateChange2() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
document.getElementById("available").innerHTML =
xmlHttp.responseText;
}
}
}
The page result.php just builds a pull down list - '<select id="size"
onchange="doRequestUsingGET2();" name="size">
I need to grab the value of <select id="Brand"
onchange="doRequestUsingGET();" name="Brand" tabindex="1"> (working
well on all browsers) and the value of Size from the innerhtml call.
These 2 values are used in listing.php which builds a table of the
results.
> > function createQueryString2() {
> > var Brand = document.getElementById("Brand").value;
[quoted text clipped - 19 lines]
> should give a script error as then getElementById returns null and you
> can't access .value on null. Do you get a script error?
Martin Honnen - 29 Jun 2006 18:01 GMT
> function createQueryString2() {
> var Brand = document.getElementById("Brand").value;
> var Size = document.getElementById("size").value;
Can you answer that:
>>Do you get a script error on
>> document.getElementById("size").value
>>with IE? If there is no element with id="size" then that expression
>>should give a script error as then getElementById returns null and you
>>can't access .value on null. Do you get a script error?
If there is no script error then IE finds the element just fine by its
id. Thus if there is no script error then the problem is not with
getElementById.

Signature
Martin Honnen
http://JavaScript.FAQTs.com/
fmdevelopertim@gmail.com - 29 Jun 2006 19:06 GMT
No script error.
I display the two variables in the PHP file and it displays:
Selected Brand is 19
Selected size is
The size variable is empty. It is being passed as:
var queryString = "brand=" + Brand + "&size=" + Size;
var queryString = "listing.php?";
queryString = queryString + createQueryString2() ;
> > function createQueryString2() {
> > var Brand = document.getElementById("Brand").value;
[quoted text clipped - 11 lines]
> id. Thus if there is no script error then the problem is not with
> getElementById.
Martin Honnen - 30 Jun 2006 13:03 GMT
> I display the two variables in the PHP file and it displays:
>
[quoted text clipped - 6 lines]
> var queryString = "listing.php?";
> queryString = queryString + createQueryString2() ;
Hard to tell without seeing a test case. Is the element with id="size" a
single or multiple select element? Does it render properly? What does
document.getElementById('size').selectedIndex
give?

Signature
Martin Honnen
http://JavaScript.FAQTs.com/
fmdevelopertim@gmail.com - 30 Jun 2006 21:25 GMT
Thanks for the reply - I figured it out based on your comments. The
list rendered correctly but the value element was not correctly
defined.
I greatly appreciate your assistance!
> > I display the two variables in the PHP file and it displays:
> >
[quoted text clipped - 11 lines]
> document.getElementById('size').selectedIndex
> give?