Ahoj mám tento script:
function keyWordsearch(){
gapi.client.setApiKey(\'AIzaSyB7oqNYxEGnskHEpKHSCbIH_-VI4_sJkzg\');
gapi.client.load(\'youtube\', \'v3\', function() {
makeRequest();
});
}
function makeRequest() {
var q = $(\'#query\').val();
var request = gapi.client.youtube.search.list({
q: q,
part: \'snippet\',
maxResults: 1
});
request.execute(function(response) {
$(\'#results\').empty();
var srchItems = response.result.items;
$.each(srchItems, function(index, item) {
vidThumburl = item.snippet.thumbnails.default.url;
vidTitle = item.snippet.title;
vidThumbimg = \'<pre><iframe id="ytplayer" type="text/html" width="640" height="390"src="http://www.youtube.com/v/\'+ item.id.videoId+\'" frameborder="0"/></pre>\';
$(\'#results\').append(\'<pre>\' + vidTitle + vidThumbimg + \'</pre>\');
});
});
}
Naplňuji ho pomocí:
<td><label> <input id="query" value="'.$song['Title'].'-'.$song['Artist'].'" type="hidden"/><button id="search-button" onclick="keyWordsearch()">Search</button></label> </td>
Jak docílit toho aby script bral v potez na co kliknu. Nyní ať kliknu na jakýkoliv řádek v tabulce vždy to bere jen ten první.
Díky za radu