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>
  • 1
    Possible duplicate of [How to access Spring MVC model object in javascript file?](http://stackoverflow.com/questions/22508773/how-to-access-spring-mvc-model-object-in-javascript-file) – Patrick Barr May 17 '17 at 16:51
  • May not be using spring, but answer should be same principle – Patrick Barr May 17 '17 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 – shaik Shaik May 17 '17 at 17:06
  • how to pass the database column to javascript – shaik Shaik May 17 '17 at 17:08
  • I'm not sure what will show up from `` 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();`, 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 – Patrick Barr May 17 '17 at 17:10
  • i dont have knowledge in json can u get the solution for that by using javascript – shaik Shaik May 17 '17 at 17:15
  • I'm not sure I follow "get the solution ... using javascript", as for JSON, it's very simple: `"{ \"propertyName1\": VALUE, \"propertyName2\": VALUE }"`. [W3 Schools Introduction to JSON](https://www.w3schools.com/js/js_json_intro.asp), I'm afraid I don't have much experience writing a Java backend, but there should be a way to get a JSON representation of `forumBean` that you can then use to set a javascript value... assuming that you have access to modify the Java side – Patrick Barr May 17 '17 at 17:31
  • http://localhost:888/ForumAnswers.jsp?Question=how%20are%20you? i get the content in address bar.. but how to show that how are you in other page – shaik Shaik May 19 '17 at 13:31
  • hey finally i got the solution... thanks for ur rply Patrick Barr – shaik Shaik May 19 '17 at 14:05

0 Answers0