I finally got this to work the way I wanted. For
anyone who is interested:
HTML - Ajaxtest.html this is the initial
html
PGM - AJAX this is an sqlrpg program. If you care
to try it, just change the declare cursor statement to point to a file that you
have with a text field. The program will build a table of the results it finds.
There may be a better way of building the output table, but I was trying to get
the onkeyup asynchronous process working and didn't spend alot of time with the
HTML.
AJAX1 is the result html.
=========================================================
AJAXTEST.html
<script type="text/_javascript_">
//**************************************************************//
var XMLhttp = false;
function GoXMLhttp()
{ //b1
try
{ //b2
XMLhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) //e2
{ //b2
try { //b3
XMLhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) { //e3b3
XMLhttp = false;
} //e3
} //e2
var input=encodeit(document.getElementById("inptext").value);
var myUrl="/cgi-bin/ajax.pgm?TEXT=" + input;
XMLhttp.
XMLhttp.open('GET', myUrl, true);
XMLhttp.send(null);
} //e1
//**************************************************************//
function XMLhttpresult()
{ //b1
if (XMLhttp.readyState == 4) { //b2
if (XMLhttp.status == 200) { //b3
var response = XMLhttp.responseText;
prodid.innerHTML = response;
} //e3
else { //b3
var alrtvar = XMLhttp.status;
alert(alrtvar);
} //e3
} //e2
} //e2
//**************************************************************//
function encodeit(value)
{ //b1
if (encodeURIComponent) { //b2
return encodeURIComponent(value);
} //e2
if (escape) { //b2
return escape(value);
} //e2
return value;
} //e1
//**************************************************************//
</script>
<html>
<head>
</head>
<body>
<table><tr><td>
<input type="text" name=inptext size=30 maxlength=30
>
<div id="prodid"></div>
</body></html>
======================================================================AJAX.PGM
/copy cgisrc/ilesrc,hspecs /copy cgisrc/ilesrc,hspecsbnd *-------------------------------------------------------------------- * Prototype defintions and standard system API error structure *-------------------------------------------------------------------- /copy cgisrc/ilesrc,prototypeb /copy cgisrc/ilesrc,usec *-------------------------------------------------------------------- * Variables common to CGI programs *-------------------------------------------------------------------- /copy cgisrc/ilesrc,variables3 *-------------------------------------------------------------------- D Lib s 10 inz('CGISRC') D Fn s 10 inz('HTMLSRC') D Mbr s 10 inz('AJAX1') d descr s 30 d intext s 30 d count s 1 inz('0') /copy cgisrc/ilesrc,prolog3 /free rc = docmd('addlible cgidev2 *last'); rc = docmd('call CHGLIBDEV'); callp gethtml(fn:lib:mbr); intext = '%' + %trim(zhbgetvarupper('TEXT')) + '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'; callp wrtsection('Top'); exsr sqldeclare; exsr sqlopen; callp updhtmlvar('response':'<table><tr><td>'); callp wrtsection('End'); exsr sqlfetch; dow sqlcod = 0; if Count = '0'; callp updhtmlvar('response':'---- Your Results Below -----'); callp wrtsection('End'); callp updhtmlvar('response':'</td></tr>'); callp wrtsection('End'); eval count = '1'; Endif; callp updhtmlvar('response':'<tr><td>'); callp wrtsection('End'); callp updhtmlvar('response':descr); callp wrtsection('End'); callp updhtmlvar('response':'</td></tr>'); callp wrtsection('End'); exsr sqlfetch; enddo; if count = '0'; callp updhtmlvar('response':'No Records!'); callp wrtsection('End'); endif; callp updhtmlvar('response':'</table>'); callp wrtsection('End'); callp wrtsection('*fini'); exsr sqlclose; *inlr = *on; return; /End-free *-------------------------------------------------------------------- ** All sql at the end *-------------------------------------------------------------------- c sqldeclare begsr c/exec sql c+ declare C1 cursor for c+ select strnam c+ from tblstr c+ where strnam like :intext c/end-exec c endsr *------------------------------------------------------------------- c sqlopen begsr C/exec sql c+ open C1 c/end-exec c endsr *------------------------------------------------------------------- c sqlfetch begsr C/exec sql c+ fetch C1 into :descr c/end-exec c endsr *------------------------------------------------------------------- c sqlclose begsr C/exec sql c+ Close C1 c/end-exec c endsr *------------------------------------------------------------------- ==========================================================================AJAX1.html/$top Content-type: text/html /$end /%response%/
YAHOO! GROUPS LINKS
- Visit your group "Easy400Group" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
