Gareth,  try/catch didn't reveal anything.
 
Frank, after numerous alerts, the problem seems to be in getAttribute(...) 
function of AJAX:
 
for (var i = 0; i < items.length; i++) {        
  alert("ID:" + items[i].getAttribute('dataID')); 
  alert("Value:" + items[i].getAttribute('dataValue'));
}
 
Here is that AppendValues(...) method
 
    function AppendValues(col,arr,label)
    {
      col.options[col.options.length] = new Option(label);
      col[col.length-1].value = arr;
    }


"Frank W. Zammetti" <[EMAIL PROTECTED]> wrote:
Ok, two things...

(1) Throw an alert in right before the call to AppendValues() :

alert(items[i].getAttribute('dataID') + " = " +
items[i].getAttribute('dataValue'));

Make sure you see the ampersand in there.

(2) Assuming you do see the ampersand in that alert, let's see the code
for AppendValues(), because it has to be where the problem is then.

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Tue, September 6, 2005 10:43 am, [EMAIL PROTECTED] said:
> Here you go Frank:
>
> AJAX CODE:
>
> function getNewXMLHttpRequest() {
> var _req;
> // branch for native XMLHttpRequest object (safari/mozilla)
> if (window.XMLHttpRequest) {
> _req = new XMLHttpRequest();
> }
> // branch for IE/Windows ActiveX version
> else if (window.ActiveXObject) {
> _req = new ActiveXObject("Microsoft.XMLHTTP");
> }
> return _req;
> }
> function getdataValues(fieldname){
> var state =
> document.actionForm.state[document.actionForm.state.selectedIndex].value;
> var url = "getXMLValues.jsp?state="+state;
> var xmlhttp = getNewXMLHttpRequest();
> xmlhttp.open("GET",url,true);
> xmlhttp.onreadystatechange = function() {
> if (xmlhttp.readyState == 4) {
> if (xmlhttp.responseXML != null) {
> var items =
> xmlhttp.responseXML.getElementsByTagName("dataSet");
> var culumnname = eval("document.actionForm." + fieldname);
> for (var i = 0; i < items.length; i++) {
> AppendValues(culumnname, items[i].getAttribute('dataID'),
> items[i].getAttribute('dataValue'));
> }
> culumnname.selectedIndex=0;
> }
> }
> }
> xmlhttp.send(null);
> }
>
>
> JSP CODE:
> > Select a State>
> > Select a Country>
>
> SERVLET CODE (modified...)
>
> ( multiple checks...)
> if (state != null && state.length() > 0) {
> searchFor = "COUNTRY_ID, COUNTRY_NAME";
> whereIs= "STATE = '" + state + "'";
> }
>
> sql = "SELECT " + searchFor + " FROM DATA_TABLE WHERE " + whereIs;
>
> Compile data from that query to xml and return to browser.
> eg:
> > dataValue="United States & US Vargin Islands" />> dataValue="Australia" />
>
>
>
> "Frank W. Zammetti" wrote:
> Let me see if I'm all caught up here (I'm just back to work from vacation
> today, so my brain isn't fully engaged yet)...
>
> Everything works as expected up until the point you try to populate the
> dropdown on the client, correct? The XML you get back from the servlet is
> correct, so the problem lies somewhere in the code to populate the
> dropdown. Sound about right?
>
> If so, can you post said code? We might be able to spot something there.
> Off-hand I can't think of what the problem might be, I don't think I've
> ever seen this before... I did see some issues with internationalized data
> at one point, but ampersand I don't think falls in that category.
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
> On Tue, September 6, 2005 10:16 am, [EMAIL PROTECTED] said:
>> Gareth, you are correct abut ajax being independent. In my case, the
>> interesting thing is that the servlet is using database to look up the
>> data and requires where cause as a parameter so that it can generate a
>> query, retrieve data from database, create xml to be passed to the
>> calling
>> .jsp page.:
>>
>> i.e.: here are the steps
>>
>> 1. onchange() getdataValues.jsp?state='NY'
>> 2. in servlet, ( multiple checks...)
>> if (state != null && state.length() > 0)
>> {
>> searchFor = "COUNTRY_ID, COUNTRY_NAME";
>> whereIs= "STATE = '" + state + "'";
>> }
>>
>> sql = "SELCT " + searchFor + " FROM DATA_TABLE WHERE " + whereIs;
>>
>> 3. compile data from that query to xml and return to browser.
>>
>> In this case, the database holds the ampersand. not the parameters that
>> are passed to the servlet. When I print out the results that the servlet
>> rturned. It looks like this:
>> > dataValue="United States & US Vargin Islands" />>
>> dataValue="Australia" />
>>
>> The drop down populates when I delete the USA record from the database.
>> So, it seems that the data that is returned needs to be parsed somehow
>> before AJAX can parse and populate the country dropdown. Does this help?
>>
>>
>> Gareth Evans wrote:
>> Hi Bob,
>>
>> Even so, the request that your making to your 'ajax servlet', the url
>> depends on the value of the
>> first select box. Somthing like 'myajaxservlet?firstvalue=Australia'
>>
>> are you building this url in javascript before making the request? thats
>> the point at which you want
>> to encode it. If you are doing it this way, the servlet will be unable
>> to
>> handle the request as you
>> expected because it will take "United States" and "US Vargin Islands" as
>> separate parameters rather
>> than a single one. Why? because '&' is used as the delimeter. If you use
>> the javascript escape
>> function e.g javascript:escape('United States & US Vargin Islands'),
>> your
>> servlet will handle this
>> as a single parameter.
>>
>> It doen't matter that your not using struts, ajax is independant of your
>> servlet side code, it could
>> be written in asp if you are that way inclined ;-)
>>
>> Gareth
>>
>>
>> ---------------------------------
>> Click here to donate to the Hurricane Katrina relief effort.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to