Reputation: 187
I'd like to be able to use a java variable as one of the attributes of my HTML tag. For example, I'd like to be able to do this:
<% String questionId = "question" %>
Question: <textarea rows="5" cols="20" name=questionId><%=question %></textarea>
Where the name attribute would equal "question". The above doesnt work; is there any possible way to do this?
Upvotes: 2
Views: 6302
Reputation: 8091
You are not using the variable you set. Means you set questionId
and accessing question
It has to be fixed as below
<% String questionId = "question" %>
Question: <textarea rows="5" cols="20" name=questionId><%=questionId %></textarea> <br>
Upvotes: 1
Reputation: 770
you've forgot the semicolon. try this it must work :
<% String questionId = "question"; %>
Question: <textarea rows="5" cols="20" name=questionId><%=question %> </textarea> <br>
Upvotes: 0