You need to realize that an <iframe> is effectively a separate page from the page it is on - it can even have elements with the same ID's as the parent page and they will not be confused.
Now - if you have two iframe's on the same page - for normal interactions they don't know anything about each other.
What they do have in common is the same parent.
So - for one frame to contact the other you must go through the parent. From the parent you can, for example, change the source of the other iframe.
Here's a references for you - to give you the idea if I wasn't clear enough:
Getting the URL of an iframe’s parent - Human Who Codes[
^]