Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple selection list

Status
Not open for further replies.

cajchris

Programmer
Oct 13, 2005
57
GB
hi,

i have a problem in that when multiple items are selected from my html form and the search button is selected, it only seems to select the selected item which is closest to the top of the list, here is my html code:

<div id="SearchArea">
<form name="searchForm" align="right" method="POST" action="/infoglueDeliverWorking/Special+Pages/Search+Results">
<input type="hidden" name="resultView" value="successXML">
<input name="searchString">
<input type="submit" value="Search">

<!-- the multiple select list -->
&#160;<select name="searchedDirectoryNames" id="selectedDirectories" size="2" multiple>
<option value="about us">about us</option>
<option value="news">news</option>
<option value="technology">technology</option>
</select>
</form>
</div>

I am not using javascript at the moment as i was told by some1 else that i didnt have to use javascript as it would automatically pick up the multiple selections as a comma seperated list. (im a relative beginner with javascript :) )

I am using a Java program which tries to get the selected items from the list by using the name - 'searchedDirectoryNames', and for example if i select about us and news elements in the list, the number of elements returned is 1, and it is about us.

I need that 'searchedDirectoryNames' to give me back an array of the selected items

regards
cajchris


 
I am using a Java program which tries to get the selected items from the list by using the name - 'searchedDirectoryNames', and for example if i select about us and news elements in the list, the number of elements returned is 1, and it is about us.
Might I suggest that the problem lies in the Java program you are using. Maybe you are not accessing the object server-side correctly... regardless, your HTML is fine and I would expect to see both values sent to the server. Try looking at the actual headers that are sent by the browser to the server when you submit the form... or maybe change the form method to be GET and watch the params in the browser location bar.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
this is the method from my java program that accesses the searchedDirectoryNames array:

public String search() throws Exception
{
log.debug("searchString: " + searchString);
log.debug("number of directories chosen: " + searchedDirectoryNames.length);
List searchDirectories = DirectoryController.getController().getDirectories(this.searchedDirectoryNames);

if (this.searchedDirectoryNames != null && this.searchedDirectoryNames.length>0)
{
for (int y = 0; y < this.searchedDirectoryNames.length; y++)
{
log.debug("directorties from jsp are" + this.searchedDirectoryNames[y]);
}
}
if (searchDirectories != null && searchDirectories.size() >0)
{
for(int i = 0; i < searchDirectories.size(); i++)
{
SearchDirectory sd = (SearchDirectory) searchDirectories.get(i);
log.debug("search directory: " + sd.getDirectoryName());
}
}

this.searchResult = searchController.search(LuceneIndexWriter.getDirectories(searchDirectories), this.searchString, this.startAt);

if (this.searchResult != null && this.searchResult.getResultItems().size() >0)
{
for(int i = 0; i < this.searchResult.getResultItems().size(); i++)
{
ResultItem ri = (ResultItem) this.searchResult.getResultItems().get(i);
log.debug("search result item: " + ri.getUrl());
}
}

this.directories = directoryController.getDirectories();

if(this.resultView == null)
this.resultView = PropertyHelper.getProperty("resultView");

return this.resultView;
//return Action.SUCCESS;
}

searchedDirectoryNames is an instance variable within this class.

regards,
cajchris
 
these are the parameters that are returned for selecting about us and news:

searchString=lorem&searchedDirectoryNames=about+us&searchedDirectoryNames=news
 
Based on what you are seeingin your location bar, the HTML is working fine, and as I suggested the problem is most likely with the Java side of things... see the bold entries below confirming the data is being sent:
searchString=lorem&searchedDirectoryNames=about+us&searchedDirectoryNames=news
I would really take this to one of the Java forums for getting this resolved.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top