title: Using input value in a javascript function
body: <p>I want to use a value of a hidden input field in my javascript function. I'm kind of a javascript noob, so I don't know how to use it yet. Now I have two seperate javascript codes which I want to combine.</p>
  
  <p>My HTML: <code>&lt;input type="hidden" id="frequentie_x" value="{$profile.x}"/&gt;</code></p>
  
  <p>My first JS code to get the value of the id frequentie_x:</p>
  
  <pre><code> &lt;script&gt; 
  
      function frequentie() { 
           window.frequentie =  
              document.getElementById("frequentie_x").value; 
      }
  &lt;/script&gt; 
  </code></pre>
  
  <p>And my second JS code which I need for displaying the correct radiobutton on my page:</p>
  
  <pre><code>&lt;script&gt;
  
      $(function () { $('input[value="(Here goes the value of input field hidden"]').filter(':visible:first').prop('checked', true)} ); 
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Does anyone know how to combine these two into one script to use the value of my hidden input value in the second script? Or maybe an easier way to do this of course.</p>
  
  <p><strong><em>Edit:</em></strong></p>
  
  <p>I tested the following code and it works to show the variable input value that is loaded from a database to show in the p element with id result:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
      function myFunction() { 
          var frequentie =  document.getElementById("frequentie").value;
                  document.getElementById("result").innerHTML = frequentie; 
            }
   $(function () { $('input[value="Dagelijks"]').filter(':visible:first').prop('checked', true)} );
  &lt;/script&gt; 
  
    &lt;p id="result"&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Now all I need is to use the var frequentie in this part: $('input[value="Dagelijks"]'). Does anyone know how to use the var frequentie from funtion myFunction() here?</p>