Originally posted by Suman Sharma:
I changed the name authorbean to authorbean2. I was using the same variable name twice that I used at some other place in this page. So c:set is working fine now.
But it is now completely ignoring the line <c:if test = "${chosen2 == $authorname2}" >
It is supposed to populate the second box with the names of books written by a particular author that is selected in the first box. But the second box is showing all the books regardless of which author name is selected in the first box. It looks like something is wrong in c:if line. Can you please help me?
<c:if test = "${chosen2 == $authorname2}" > this test is done server-side where chosen2 is no attribute in the application.
But you can solve the problem:
var js_authorname2='${authorname2}';
and make the test in javascript:
if (chosen2 == js_authorname2) {
// anything you want to do in javascript;
// you can surely use any JSTL expressions
}
P.S.
<c:out value="${authorname2}" /> : this is not good at this place it will break your javascript code
--> instead of it you can write: alert('${authorname2});
<c:if test = "${chosen2 == $authorname2}" >
this has wrong syntax
--> <c:if test = "${chosen2 == authorname2}" >
if ever used: chosen2 and authorname2 must both be attibutes in any scope: page, request, session or application
But like i said this is not the right way --> use javascript instead.
[ October 19, 2008: Message edited by: Salah Lejmi ]