warrenjb
warrenjb

Reputation: 25

alternate ideas for working with dynamically named html elements

I am creating .jsp page elements dynamically by looping through a table (say table tquestions with columns question_id and question_txt) using a <c:forEach> loop and creating label elements using the question_txt values, and text inputs with name and id equal to the question_id values (i.e. <inputs type="text" id=${row.tquestion_id}" name="${row.tquestion_id}">).

On submit, I want to write the posted element values to another table (say tanswers with columns tanswer_id, tanswer_txt, tquestion_id). The tanswer_txt column should be set to the element value with it's name and id equal to the corresponding tquestion_id from the submitted page.

I thought if I requeried and looped through the tquestion table again and set my SQL:param values using this new loop, I could easily update the table - until I started coding and realized I'm updating the tanswer table with my new loops values rather than the values from the submitted page. In other words, I would need the sql:param to look something like <sql:param value = "${param.${row.tquestion_id}}"> which I understand cannot work.

I hope this question makes sense. I don't have my laptop with the code on it with me but I can update this post later if there are no suggestions based on this post alone. Thank you in advance for any thoughts.

Upvotes: 0

Views: 16

Answers (0)

Related Questions