Still fighting with this.
Since I've taken the variables out of the javascript it is called like this
<select name="subcategory" id = "subcategory" onchange="showSubcategory2()">
But firebug keeps showing the error as
missing ) after argument list
showSubcategory2(document.getElementById()
I'm looking forward to getting the book next week but this is driving me
up the wall.
Related question why is it bad web standards to use onchange and the
like. Up until know everything I've seen online makes that type of use
normal.
Michael Horowitz
Your Computer Consultant
http://yourcomputerconsultant.com
561-394-9079
Kit Grose wrote:
The issue is that selects themselves don't have values. You notice the
value is on the option tag, not the select.
So you can't just get the .value of the element with ID 'subcategory';
you need to get the value of the currently selected item OF that
select box. That can be done as an inline declaration, but shouldn't be.
The best bet is to get both values within the showSubcategory2
function. Remove both parameters to the showSubcategory2 function and
calculate them in the function:
HTML:
<select name="subcategory" id = "subcategory"
onchange="showSubcategory2()">
JavaScript:
function showSubcategory2() {
var categorySelect = document.getElementById('category');
var subcategorySelect = document.getElementById('subcategory');
var category =
categorySelect.options[categorySelect.selectedIndex].value;
var subcategory =
subcategorySelect.options[subcategorySelect.selectedIndex].value;
xmlHttp = GetXmlHttpObject();
if (xmlHttp == null) {
alert ("Browser does not support HTTP Request");
return;
}
var url = "getsubcategory2.php";
url = url + "?category2="+category;
url = url + "&subcategory2="+subcategory;
url = url + "&sid="+Math.random();
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
...or better yet, remove the onchange attribute from your select tag
completely and implement the onchange unobtrusively as I detailed last
time.
Hope that helps,
Kit
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************