First things first, you HTML is
illegal. Because there is only one ID allowed with a specified identifier string. Yours has 3 of them. Change the HTML to this one,
<div class="ow_chat_dialog" id="main_tab_contact_11">
<iframe class="myframe"></iframe>
<button onclick="setsrc()"></button>
</div>
<div class="ow_chat_dialog" id="main_tab_contact_12">
<iframe class="myframe"></iframe>
<button onclick="setsrc()"></button>
</div>
<div class="ow_chat_dialog" id="main_tab_contact_13">
<iframe class="myframe"></iframe>
<button onclick="setsrc()"></button>
</div>
This is why you use class to group elements of same type. The problem that it selected the first, was because it started looking for any element with an ID of myframe, and the first one it found was applied with the source of resource.
Secondly, to get the nearest, or the iframe inside the same parent you can use any of the following methods, do use jQuery to make things a little simple.
Finding from the same parent
$(document).ready(function () {
$('button').click(function () {
$(this).parent().find('iframe').attr('src', "http://www.locationofresource.com/page.html";
});
});
This code, would find the iframe inside the same parent where the button is present and will update the source of it.