title: Search youtube and display results on my website
body: <p>How do I search youtube from my site and display the results on the same page underneath?  I have managed to add a search feature with the following code:</p>
  
  <pre><code>&lt;form action="http://www.youtube.com/results" method="get" target="_blank"&gt;
  &lt;input name="search_query" type="text" maxlength="128" /&gt;
  &lt;/select&gt;
  &lt;input type="submit" value="Search" /&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>However, it opens a new page.  I have also tried to replace the "_blank" with the name of an iframe, but that didn't work either:</p>
  
  <pre><code>&lt;form action="http://www.youtube.com/results" method="get" target="iframe_a"&gt;
  &lt;input name="search_query" type="text" maxlength="128" /&gt;
  &lt;/select&gt;
  &lt;input type="submit" value="Search" /&gt;
  &lt;/form&gt; 
  
  &lt;iframe src="demo_iframe.htm" name="iframe_a"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>Thanks</p>
  
  <p>I came across the code at the following site.  It just what I'm looking for and it seems like it should work, but it doesn't.  Anyone have an idea of were the code is wrong?
  <a href="http://codeapi.blogspot.com/search/label/Video%20Widget" rel="nofollow">http://codeapi.blogspot.com/search/label/Video%20Widget</a></p>
  
  <pre><code>&lt;script type="text/javascript" src="jquery-1.6.2.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  function SearchYouTube(query) {
  $.ajax({
      url: 'http://gdata.youtube.com/feeds/mobile/videos?alt=json-in-script&amp;q=' + query,
      dataType: 'jsonp',
      success: function (data) {
          var row = "";
          for (i = 0; i &lt; data.feed.entry.length; i++) {
              row += "&lt;div class='search_item'&gt;";
              row += "&lt;table width='100%'&gt;";
              row += "&lt;tr&gt;";
              row += "&lt;td vAlign='top' align='left'&gt;";
              row += "&lt;a href='#' &gt;&lt;img width='120px' height='80px' src=" + data.feed.entry[i].media$group.media$thumbnail[0].url + " /&gt;&lt;/a&gt;";
              row += "&lt;/td&gt;";
              row += "&lt;td vAlign='top' width='100%' align='left'&gt;";
              row += "&lt;a href='#' &gt;&lt;b&gt;" + data.feed.entry[i].media$group.media$title.$t + "&lt;/b&gt;&lt;/a&gt;&lt;br/&gt;";
              row += "&lt;span style='font-size:12px; color:#555555'&gt;by " + data.feed.entry[i].author[0].name.$t + "&lt;/span&gt;&lt;br/&gt;";
              row += "&lt;span style='font-size:12px' color:#666666&gt;" + data.feed.entry[i].yt$statistics.viewCount + " views" + "&lt;span&gt;&lt;br/&gt;";
              row += "&lt;/td&gt;";
              row += "&lt;/tr&gt;";
              row += "&lt;/table&gt;";
              row += "&lt;/div&gt;";
          }
          document.getElementById("search-results-block").innerHTML = row;
      },
      error: function () {
          alert("Error loading youtube video results");
      }
  });
  return false;
  }
  &lt;/script&gt;
  
  &lt;input type="text" id="queryinput" /&gt;
  &lt;input type="submit" value="Search" 
  onclick="javascript:SearchYouTube(document.getElementById('queryinput').value)" /&gt;
  &lt;div id="search-results-block"&gt;&lt;/div&gt;
  </code></pre>