Javascript: Setting variable to work in attr line
<p>Kinda of a noob question, can't seem to solve it, but I may just be tired.</p>

<p>What I'm trying to do is insert a PHP variable in to Javascript (Jquery), and then that variable in to an attr line.</p>

<p>The script I'm using to create the variable:</p>

<pre><code>$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
    for(var i = 0; i &lt; hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});
</code></pre>

<p>Setting the variable:</p>

<pre><code>var searchresult =  $.getUrlVar('s');
</code></pre>

<p>And then, where I'm stuck, inserting the variable within the line so that'll come out correctly when I send it off to my iframe.</p>

<pre><code>  $(function() {

  $("#searchbutton").click(function() {

     $("#theiframe").attr("src","http://whateverdomain.com/index.php?s=VARIABLE HERE WITHIN JAVASCRIPT");
  })

})
</code></pre>

<p>I know, kinda beginners question going here, but I admit it, I'm stuck.</p>
