Hi All,
I have written a AutoSuggest in jsp and am using javascript to call the strut page which calls the database and returns me the xml back.
On the html page i have a text box where i enter the name of the city and I have a DIV tag which I populate with the results.
Now my problem is that, after I get the results back I am not able to select a value from the DIV tag.
Here is the complete jsp code.
[HTML]<html>
<head>
<link style><a href="newCascad eStyleSheet.css "></a>
<script language="javas cript">
/*
* Returns an new XMLHttpRequest object, or false if the browser
* doesn't support it
*/
var availableSelect List;
function newXMLHttpReque st() {
var xmlreq = false;
// Create XMLHttpRequest object in non-Microsoft browsers
if (window.XMLHttp Request) {
xmlreq = new XMLHttpRequest( );
} else if (window.ActiveX Object) {
try {
// Try to create XMLHttpRequest in later versions
// of Internet Explorer
xmlreq = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e1) {
// Failed to create required ActiveXObject
try {
// Try version supported by older versions
// of Internet Explorer
xmlreq = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (e2) {
// Unable to create an XMLHttpRequest by any means
xmlreq = false;
}
}
}
return xmlreq;
}
/*
* Returns a function that waits for the specified XMLHttpRequest
* to complete, then passes it XML response to the given handler function.
* req - The XMLHttpRequest whose state is changing
* responseXmlHand ler - Function to pass the XML response to
*/
function getReadyStateHa ndler(req, responseXmlHand ler) {
// Return an anonymous function that listens to the XMLHttpRequest instance
return function () {
// If the request's status is "complete"
if (req.readyState == 4) {
// Check that we received a successful response from the server
if (req.status == 200) {
// Pass the XML payload of the response to the handler function.
responseXmlHand ler(req.respons eXML);
} else {
// An HTTP problem has occurred
alert("HTTP error "+req.statu s+": "+req.statusTex t);
}
}
}
}
function search(searchKe y) {
var form = document.forms[0];
var keyValue = document.getEle mentById("getCi ties").value;
keyValue = keyValue.replac e(/^\s*|\s*$/g,"");
if (keyValue.lengt h > 1)
{
availableSelect List = document.getEle mentById("searc hResult");
var req = newXMLHttpReque st();
req.onreadystat echange = getReadyStateHa ndler(req, update);
req.open("POST" ,"<%=request.ge tContextPath()% >/searchCity.do", true);
req.setRequestH eader("Content-Type", "applicatio n/x-www-form-urlencoded");
req.send("getCi ties="+keyValue );
}
}
function update(cartXML)
{
var countries = cartXML.getElem entsByTagName(" cities")[0];
//availableSelect List.options.le ngth = 0;
var country = countries.getEl ementsByTagName ("city");
availableSelect List.innerHTML = '';
for (var i = 0; i < country.length ; i++)
{
ndValue = country[i].firstChild.nod eValue;
availableSelect List.innerHTML += ndValue +"<BR>\n";
}
}
</script>
</head>
<body>
<form action="/searchCity" id="searchByCit yForm">
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td ><B>Event Title</b></td>
</tr>
<tr>
<td class="promo">
<table border="0" cellpadding="3" cellspacing="0" >
<tr>
<td valign="top">
<input type="textbox" id="getCities" size="20" onKeyDown="sear ch(this);" style="width:30 0px;" autocomplete="o ff" >
<div id="searchResul t" name="searchRes ult" style="z-index: 1; left: 5px; top: 50px; width: 300px;
height: 370px; background-color:#003366; layer-background-color:#003366;" ></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>[/HTML]
In the searchResult div section, which is populated from availableSelect List, I cannot do a select one value ...can anyone suggest something??
Let me know if you need more info on how the jsp page looks in the browser
3 2401 acoder 16,027
Recognized Expert Moderator MVP
How do you want to select the value? Using a dropdown select element? If so, you'll need to create it.
Can you give an example code to show me ?
acoder 16,027
Recognized Expert Moderator MVP
You can create a select element with: - var selObj = document.createElement("select");
You'll need to append it to the body or div using appendChild. To append options to it: - var opt = document.createElement('option');
-
opt.text = theTextToBeDisplayed;
-
opt.value = theValue;
-
try {
-
selObj.add(opt, null); // standards compliant way
-
} catch(exc) {
-
selObj.add(opt); // for IE only
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bob Bedford |
last post by:
I've a form that use a combobox along with other fields. When the user
submit the form, many tests are done. If any test fails, then I show the
form again with previously entered values.
My problem: when I show back the form with previously entered values, I
can't set the entered value of the combobox. I've registered the value, but
how to go trough the value, and select the right one.
I'd like something like:
|
by: yankee |
last post by:
Hi all,
I have the following HTML code:
<form>
<table border=1 cellspacing=0 cellpadding=3>
<tr>
<td>Select a Document:</td>
<td><SELECT name="type" id="type">
<OPTION
|
by: @sh |
last post by:
Probably very simple, but I have a SELECT box The value of each option in
the Select box will be a number, for instance...
<option value="5">A test entry</option>
Therefore, how do I, via an onClick, change the selected option of a Select
via the Value of the select only? I can't use the 'selectedIndex' because it
doesn't relate to the value of the option.
Thanks!
|
by: sensreview |
last post by:
Hello,
I need help in selecting a value from combo list thru one lookup table and update different table on MS access form.
For eg; I have a lookup table of usernames,
I need to use this lookup table in all my other forms to update different table selecting the username from my lookup table.
I tried Docmd.runsql but unable to succeed.
|
by: Thad |
last post by:
In the html I have a select option. I am trying to get the result of the
selection(u5503_qty*5) to print after some text. I am having a problem
grabbing the value of u5503_qty from the html to use in the javascript. Can
somebody correct me on this?
Step 4. How many would you like?<br />
<select name="u5503_qty" size="1">
<option label="1" value="1" selected>1</option>
<option label="2" value="2">2</option>
| |
by: billypit |
last post by:
Hi,
I am totaly new to MS Access.
I have one form in MS Access in which i want that whenever i select an item from combobox then in the textbox on the same form or subform i want value from table based on selection from combobox.
like
in my table there two fields
ID,name
1 billy
2 sandy
|
by: viki1967 |
last post by:
Hello.
It's possible at this select when you select only the value BBB automatically open a web page in the window popUp ?
<form method="POST" action="next.asp">
<p>
<select size="1" name="D1">
<option>Select</option>
<option value="AAA">AAA</option>
<option value="BBB">BBB</option>
|
by: Haitashi |
last post by:
Snippet: <form>
<select name="secCode" id="secCode">
<cfloop query="Request.qSecCodes">
<option value="#Request.qSecCodes.org_name#" <cfif (Request.qSecCodes.org_code EQ Variables.oSurvey.secCode)>selected="true"</cfif>>#Request.qSecCodes.org_name#</option>
</cfloop>
</select>
</form>
As you can see, I'm populating that select with the results of a query. I wanted to have a value selected by default. That's what the CFIF was put...
|
by: viki1967 |
last post by:
Hello everyone.
Try this htm page, please:
http://users1.titanichost.com/MiguelRivero61/
This is the code:
<html>
|
by: balajihr |
last post by:
Hi All,
The below query works well, but I'm unable to select * columns or selected columns from 2 tables.
select FIAS_ID, ACTION_ID from CTH_ABAL_FIAS_HISTORY
where ACTION_ID = 535 OR ACTION_ID = 536
union all
select FIAS_ID, ACTION_ID from CTH_ABAL_FIAS_DEPTH_HIST;
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |