Hey everyone,

I'm working on some javascript code. What i have now is a list box that contains certain elements and another list box, blank at the moment, next to it. I want, when someone clicks an element within the first list box, that in the background, a MySQL statement is run that will select everything pertaining to the selection. Like "SELECT * from TABLE_NAME WHERE coulumn = SELECTED ELEMENT". I was hoping someone could point me in the right direction as to how to perform this. Thanks!

-barefoot

May not be possible, use server side script like php

AJAX maybe, to connect to a Servlet (or some other serverside program) that returns the results.

But, in any case, this is a JSP/Java forum, not JavaScript, please post this type of question in a JavaScript forum, next time. I have already asked the admins to move this one.

Ooops. Sorry. I clicked the wrong forum.

Thanks for the responses though. Would it be possible to run a PHP script through a javascript call?

This example does exactly what you want. Also try to read a few links from this page if you plan on some serious stuff with possibly a good book by your side.

Well you require a combination of JSP and JavaScript. I don't have the code right now but will work on it and provide it to you. The logic is:

1) Retrieve a java.util.List of Objects from database in a user session.

2)Iterate over the java.util.List and populate the objects in HTML list.

3)Use Java Script and use onClick/onChange method of list to call another Servlet/JSP.

4) Use <jsp:include> to embed the second JSP with an html list in the first JSP.

5) Write the logic for populating the html list in the second JSP with the elements of the first one

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.