0

How to pass the database column to javascript function in jsp or html

function forumQuestions(questions){
document.getElementById("questions").value = questions;
 document.getElementById("questions").submit();

}

<a href="javascript:forumQuestions()"><c:out value="${forumBean.questions}"></c:out></a></td>
9
  • 1
    Possible duplicate of How to access Spring MVC model object in javascript file? Commented May 17, 2017 at 16:51
  • May not be using spring, but answer should be same principle Commented May 17, 2017 at 16:53
  • actually it is a forum page.... i retrieve the data from database... when i click on the data ... same content has to shown in other page thanks for your rply Commented May 17, 2017 at 17:06
  • how to pass the database column to javascript Commented May 17, 2017 at 17:08
  • I'm not sure what will show up from <c:out value="${forumBean.questions}"></c:out> but your best bet is to either make sure that it's a valid javascript value, or make it a JSON string and use var data = JSON.parse(<c:out value="${forumBean.questions}" />);, if it's not a proper javascript value without making it a JSON string, there will most likely be a syntax error in the console Commented May 17, 2017 at 17:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.