HELP!Struggling to display the database value using select options!


#1

Check This code.
(main.htm)

   <select name="addcollege" class="addcollege" id="addcollege" value="addcollege" font-size:18px>
                          <option value="">--Select College--</option>
                  <option value="NIT-Warangal" id="NIT-Warangal">NIT-Warangal</option>  {{#if show}}Rank: {{show.rank}} {{/if}}

client/app.js

Template.table.events({ 'change #addcollege': function(event, template){ var selectValue = $("#addcollege").val();    'show': function() {

return College.find({'name':selectValue}).fetch(); }

Common.js

College = new Mongo.Collection('colleges');    if (Meteor.isServer) {  if (College.find().count() === 0) {College.insert({
rank:10,
name: "NIT-Warangal" , ) }

I was struggling in selecting the select options…i tried to use session variables…tried to retrieve but just can’t figure it out…My intention is…in the first table…if i select NIT-Warangal…it should show the components…See the client app.js… i use {{#if show}}…in show() function…i retrieved the value of the college… n i displayed as {{show.rank}} … but ain’t working…Can u please spare 5 minutes n make it working please…


#2
<template name="table">
   <select name="addcollege" class="addcollege" id="addcollege" value="addcollege" font-size:18px>
      <option value="">--Select College--</option>
      <option value="NIT-Warangal" id="NIT-Warangal">NIT-Warangal</option>  
   </select>

   {{#if show}
       {{show.rank}}
   {{/if}}
</template>

Template.table.events({ 
   'change #addcollege': function(event, template) { 
      var selectValue = $("#addcollege").val(); 
      Session.set('selectValue', selectValue);
   }
});

Template.table.helpers({ 
   'show': function() {
       var selectValue = Session.get('selectValue');
       return College.findOne({name: selectValue});
   }
});