Meteor changing form value


I’m trying to change the values of some input fields only once upon page being loaded. For example submit_date_year should be current year, so 2017 right now.


<template name="trip_html">
    <table class="table table-striped table-condensed table-hover rsk-tbl vScrollTHead">
          <td><input class="form-control input-lg" name="submit_date_day" type="text" placeholder="Day"/>  </td>
           <td><input class="form-control input-lg" name="submit_date_month" type="text" placeholder="Month"/>  </td>
            <td><input class="form-control input-lg" name="submit_date_year" type="text" placeholder="Year"/>  </td>


On page load function

    Template.trip_html.rendered = function(event, template) {
     = 'test'; // DOES NOT WORK
          console.log('Template onLoad');

However, I cannot use in that on load function, for some reason…
But it works in events, once I click ‘submit’ button{
    "submit .add-trip": function(event){
    var day =;
    var month =;
    var year =;
    var car =;
    var b =;
    var a =;
    var dist =;
    if(empty(day) || empty(month) || empty(year) || empty(car) || empty(b) || empty(a) || empty(dist)){
    return false;
    if(!isNumeric(day) || !isNumeric(month) || !isNumeric(year) || !isNumeric(dist)){
    	return false;
    day = day.replace("0", "");
    month = month.replace("0", "");
    year = year.replace("0", "");
    console.log(day, month, year, car, a, b, dist);'addTrip', day, month, year, car, a, b, dist); =; = ''; = '';

Help please!

With Blaze (Meteor’s default templating engine) you shouldn’t access your template elements using and similar constructs. Instead, you should use Blaze helpers. See here for some examples on how this works:

How do I use Blaze helpers for initial page load? Template.trip_html.rendered = function() works, but how do I do this with a helper?

What he’s trying to say is that you should use a helper as the value attribute of the form control.

<template name="trip_html">
   <input name="submit_date_year" value={{submit_date_year_helper}} />
1 Like