Hi,
I'm new to this topic and need your help!!
I created a jsp-Page with a form:
Code:
<script type="text/javascript" src="ajaxjs.js"></script>
<table border=0 cellSpacing=1 cellPadding=3 width="80%" align=center>
<form action="javascript:loadContent('5','name','','plz','ort')" method="post">
<!-- header row -->
<tbody>
<tr>
<th class=proFormMainHeader width="100%" colSpan=7 align=left>Suche 1</th>
<tr>
<td class=proFormRowOdd width="10%" align=left>Name: </td>
<td class=proFormRowOdd width="15%" align=left>
<input style="WIDTH: 100%" name="Name"> </td>
<td class=proFormRowEven width="10%" align=left>PLZ: </td>
<td class=proFormRowEven width="15%" align=left>
<input style="WIDTH: 100%" name="PLZ"> </td>
<td class=proFormRowOdd width="10%" align=left>Ort: </td>
<td class=proFormRowOdd width="15%" align=left>
<input style="WIDTH: 100%" name="Ort"> </td>
<td class=proFormRowEven width="15%" align=right>
<input type="submit" name="submit" value="submit" />
<input type="reset" name="reset" value="reset" />
</td>
</tr>
<!-- separator -->
<tr>
<td style="padding: 0px" class=proFormMainHeader colSpan=7>
<IMG alt="" src="images/web/common/Spacer.gif" width=1 height=3>
</td>
</tr>
</tbody>
</form>
</table>
The ajaxjs.js
Code:
var xmlhttp;
var divname = "search_found";
function loadContent(str, name, strasse, plz, ort)
{
xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
{
alert ("Your browser does not support Ajax HTTP");
return;
}
var url="getErgebnis.jsp";
url=url+"?q="+str+"&n="+name+"&s="+strasse+"&p="+plz+"&o="+ort;
xmlhttp.onreadystatechange=getOutput;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function getOutput()
{
if (xmlhttp.readyState==4)
{
document.getElementById(divname).innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
And getErgebnis.jsp
Code:
<%
int q = Integer.parseInt(request.getParameter("q"));
String n = request.getParameter("n");
String s = request.getParameter("s");
String p = request.getParameter("p");
String o = request.getParameter("o");
out.print("q: " + q+ " und name: " + n+ " und strasse: " + s+ " und plz: " + p+ " und ort: " + o);
String antwort = "";
String rowClass = "";
antwort =
"<table align=\"center\" border=\"0\" cellPadding=\"3\" cellSpacing=\"1\" width=\"90%\">"
+ "<tr>"
+ "<th align=\"left\" class=\"proFormMainHeader\" width=\"16%\"></th>"
+ "<th align=\"left\" class=\"proFormMainHeader\" width=\"16%\">IKP-Nr.</th>"
+ "<th align=\"left\" class=\"proFormMainHeader\" width=\"16%\">Name</th>"
+ "<th align=\"left\" class=\"proFormMainHeader\" width=\"16%\">Strasse</th>"
+ "<th align=\"left\" class=\"proFormMainHeader\" width=\"16%\">PLZ</th>"
+ "<th align=\"left\" class=\"proFormMainHeader\" width=\"16%\">Ort</th>"
+ "</tr>";
for (int i = 0; i < q; i++) {
if (i % 2 == 0) {
rowClass = "proFormRowEven";
} else {
rowClass = "proFormRowOdd";
}
antwort += "<tr>"
+ "<td align=\"left\" class=\"" + rowClass + "\" width=\"16%\">"
+ "<input type=\"radio\" name=\"rowArray." + i + ".selected\">"
+ "</td>"
+ "<td align=\"left\" class=\"" + rowClass + "\" width=\"16%\">1234</td>"
+ "<td align=\"left\" class=\"" + rowClass + "\" width=\"16%\">Musterfrau</td>"
+ "<td align=\"left\" class=\"" + rowClass + "\" width=\"16%\">Musterweg 5</td>"
+ "<td align=\"left\" class=\"" + rowClass + "\" width=\"16%\">09876</td>"
+ "<td align=\"left\" class=\"" + rowClass + "\" width=\"16%\">Musterort</td>"
+ "</tr>";
}
antwort += "<!-- separator -->"
+ "<tr>"
+ "<td colspan=\"6\" class=\"proFormMainHeader\" style=\"padding: 0px\">"
+ "<img src=\"images/web/common/Spacer.gif\" width=\"1\" height=\"3\" />"
+ "</td>"
+ "</tr>"
+ "</table>";
out.print(antwort);
%>
Now I want to pass the form input to my getErgebnis.jsp. I need them for a web service search.
How do I do this? Is this the right way?
Please help
Avallyn