I am developing a web application using Tornado framework. Currently I am working on a front end view. This page actually displays a list of ids and a small note about that id. (Its a table with two columns)
id -------- Note
100 ----- Note on 100
101 ----- Note on 101
![Table with link on id and note on id][1]
The ids are displayed dynamically. When I click on the id (its a link- anchor tag), it should take me to another page which has all the details about that id.
Approach - I thought of creating a cookie which will store the value of the id clicked, and get the cookie in tornado handler and retrieve all information about that id and send it to the next view.
The code so far is -
HTML
<table class="table table-striped" id="tableid">
<tbody>
<tr>
<th>Config ID</th>
<th>Note</th>
</tr>
<tr>
{% for d in data %}
<td>
<a onclick = "configidCreateCookieFunction()" href="/SelectedConfig" name = "configid" id ="configid">{{ d[0] }}</a></td>
<td> {{ d[1]}}</td>
{% end %}
</tr>
<tbody>
</table>
</div>
So on clicking the link it would store the value of the id, and then the link points to a handler where I can get the cookie and retrieve more information about that id.
JavaScript
<script type="text/javascript">
function configidCreateCookieFunction(){
var cid = document.getElementById("configid").innerHTML;
sessionStorage ['configid'] = cid
}
Tornado code -
class SelectedConfigHandler(BaseHandler):
def get(self):
configid= None
configid = self.get_cookie("configid")
print configid
But this is not working. When I print the id -its getting displayed as None.
So basically I am not able to pull the value of the id which is a link, and the id is basically coming from the database Please help me out. Is my approach correct?
Thanks in Advance