JQuery - add value to the hidden input
<p>How can add value to the hidden input filed? In this case input is being created as variable, and latter on inserted into the DOM if needed. The code:</p>

<pre><code>&lt;script&gt;
    var forma = $('form#mali_oglas'),
    pomoc = $('div[role=pomoc]'),
    div = $('.mali_oglas_pomoc'),
    input = forma.find('input, textarea'),
    code = forma.find('#code')
    time_input = '&lt;input type="hidden" name="time" /&gt;',
    paid_input = '&lt;input type="hidden" name="paid" value="1" /&gt;';

    $('textarea').autosize();

    input.on('click', function(e){
        var name = $(':input:focus').attr("name");
        pomoc.fadeOut('slow').promise().done( function(){
         div.find("[data-pomoc='" + name + "']").fadeIn('slow');
     });
    });


    code.on('focusout', function(){
        var url = '&lt;?php echo base_url() ?&gt;global_info/gi_get_payment_code',
        kod = $(this).val();
if ($('input[name=paid]').length != 1)
    {
        $.post(url, {code : kod}, function(data){
            console.log(kod);
            $('.mali_oglas_img_paid').slideDown('slow');
            code.next('.mali_oglas_greska').remove();
            code.after(time_input.val(data) + paid_input)
            .css({'border' : '1px solid rgba(34,139,34,.5)'});
        });
    };
    });

    code.ajaxError(function() {
  $(this).next('.mali_oglas_greska').remove();
  $(this).after('&lt;p class=mali_oglas_greska&gt;Uneti kod je pogresan.&lt;/p&gt;').css({'border' : '1px solid rgba(255,0,0,.5)'});
});
&lt;/script&gt;
</code></pre>
