I have a website where a list is printed using a function and <%= %>
to print it. I then want to change the value in a separate <div>
when an item in the list is selected.
Here is the function that creates the string:
public String createInfoString(String s){
JavaBeans.CatalogueBean c = new JavaBeans.CatalogueBean();
JavaBeans.ProductBean pb[] = c.getProducts();
int posit = Integer.parseInt(s);
String tempStr =
"<img src='Images" + pb[posit].getImageExtention() + "' width='400' height='300'></img> </BR></BR>"+
"Model: " + pb[posit].getName()+ "</BR></BR>" +
"Description: " + pb[posit].getDescription() + "</BR></BR>"+
"Number in stock: " + pb[posit].getNumAvailable() + "</BR></BR>";
return tempStr;
}
The Code for the list is as follow:
<ul onclick="createInfoString(event.srcElement.id)">
<li>
<div class="Folder">Accessories</div>
</li>
<%= createSideList()%>
</ul>
When an item is clicked, I need to generate a string(this is done by createInfoString
), I then need to push that string into a <DIV>
, Can anyone show me how to do this?
with JavaScript i would have used
document.getElementbyID("DisplayInfo").innerHTML = tempStr
.
But this does not work with jsp
.
Please Help...
The JSP is executed at server-side. If you need to do something when somethin is clicked, it must be done at client-side, in JavaScript.
So you basically have two possibilities:
DisplayInfo
div. DisplayInfo
div.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.