Hai Friends,
I have the code like this.
Here my issue is: when the user accesses this page he will get the topic and related categories in the drop down boxes. but when the user changes the topic it needs to populate the categories from the database and kept the topic same for the respective categories. so how can i do this?

<form name="questionForm" method="post" action="listQuestions.lgs">
<table bgcolor="F8D8D8" cellspacing="2" cellpadding="2" align="center"
style="margin-top: 100px">
<tr>
<td>Topics:</td>
<td><select name="topic">
<c:forEach items="${model.topics}" var="topic">
<option value="<c:out value="${topic.topicId}" />"><c:out
value="${topic.topicName}" /></option>
</c:forEach>
</select></td>
<td>Categories:</td>
<td><select name="category">
<c:forEach items="${model.categories}" var="category">
<option value="<c:out value="${category.categoryId}" />"><c:out
value="${category.categoryName}" /></option>
</c:forEach>
</select></td>
<tr>
<td><a
href="addQuestion.lgs?categoryId=2<c:out value="${category.categoryId}"/>">Add
New Question</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Questions under this Category:</td>
<td><c:if test="${model.questions} == null">
<c:out value="no questions found" />
<br>
</c:if> <c:if test="${model.questions} != null">
<c:forEach items="${model.questions}" var="question">
<table>
<tr>
<c:out value="${question.questionDesc}" />
</tr>
</table>
</c:forEach>
</c:if></td>
</tr>
<tr>
<td colspan="2"><input type="submit" /></td>
</tr>
</table>
</form>

Hi,
There are many ways you could solve this issue and depending on your target audience, you may have to implement more than one solution.

A favourite approach is to use an AJAX solution. This requires knowledge of JavaScript and a server page that provides categories based on topic.

However, this would be overkill, unless there is a lot of information for each topic. So I'd load all of the possible topic categories when the page is drawn on the server. Then just use a little JavaScript to display/hide the relevant category.

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.