F
Frances
I literally started learning AJAX just last weekend.. I have this page,
http://www.francesdelrio.com/ajax/db2.html, where I'm essentially doing
what's here, http://www.w3schools.com/ajax/ajax_source.asp, only my
array is populated from info pulled from db.. I added interface to HTML
interface to insert info into db; info gets inserted in to db in a
servlet then servlet redirects back to HTML interface, where if user
types something from array (array of First Names column in db table) it
gets printed about two lines down..
now what I would like to do, if possible, is on top, instead of putting
an input type-text, do a select obj and populate it with all First Names
in db table (which are in array), like here,
http://www.francesdelrio.com/ajax/getData3.jsp.. what I tried:
I repeated this function
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}
giving it a diff. name (stateChanged2()) and changed id for div... and
call function for populating sel obj when pg loads, but select obj is
not appearing.. (I have no idea if you can do this, if with AJAX you can
only change state upon user input and not when HTML pg loads.. but it
seems to me I should be able to call an AJAX function -- like any
function -- when pg loads..)
so: have two 'main' functions (for lack of a better term -- I mean the
functions that call the XMLHttpRequest obj and call stateChanged()
functions..) one for printing sel Obj w/info from db when pg loads and
one for printing text on pg according to what user selects in sel obj..
each function calls a diff JSP (don't know yet how to do this with
both functions calling same JSP, as this line
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
just prints whatever is output in JSP (don't know yet if/how you say,
here print this part of JSP and here print this other part of JSP..) I
hope all this makes sense.. all relevant code is JavaScript, so you can
easily view... pg where I'm trying to do all this is
http://www.francesdelrio.com/ajax/db3.html
many thanks..
Frances
http://www.francesdelrio.com/ajax/db2.html, where I'm essentially doing
what's here, http://www.w3schools.com/ajax/ajax_source.asp, only my
array is populated from info pulled from db.. I added interface to HTML
interface to insert info into db; info gets inserted in to db in a
servlet then servlet redirects back to HTML interface, where if user
types something from array (array of First Names column in db table) it
gets printed about two lines down..
now what I would like to do, if possible, is on top, instead of putting
an input type-text, do a select obj and populate it with all First Names
in db table (which are in array), like here,
http://www.francesdelrio.com/ajax/getData3.jsp.. what I tried:
I repeated this function
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}
giving it a diff. name (stateChanged2()) and changed id for div... and
call function for populating sel obj when pg loads, but select obj is
not appearing.. (I have no idea if you can do this, if with AJAX you can
only change state upon user input and not when HTML pg loads.. but it
seems to me I should be able to call an AJAX function -- like any
function -- when pg loads..)
so: have two 'main' functions (for lack of a better term -- I mean the
functions that call the XMLHttpRequest obj and call stateChanged()
functions..) one for printing sel Obj w/info from db when pg loads and
one for printing text on pg according to what user selects in sel obj..
each function calls a diff JSP (don't know yet how to do this with
both functions calling same JSP, as this line
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
just prints whatever is output in JSP (don't know yet if/how you say,
here print this part of JSP and here print this other part of JSP..) I
hope all this makes sense.. all relevant code is JavaScript, so you can
easily view... pg where I'm trying to do all this is
http://www.francesdelrio.com/ajax/db3.html
many thanks..
Frances