...

View Full Version : Dont really know the subject, has to do with popups



DigitalBliss
04-14-2005, 10:16 PM
Hey I wanted to make something where when a person clicks a link a popup comes in the center of the page with a whole list of usernames. When the person clicks a username the popup closes and the username appears in a textbox. How can I do this?

brandonH
04-14-2005, 10:27 PM
the pop up is a child window of the original window...
you need a script in the child source code that does this:

<body>
<a href=#stayhere id='username1' onclick='LinkV(this.id);'>username1</a>
</body>

<script language=javascript>
function LinkV(val){
opener.document.getElementById('textarea').value=val;
window.close();
}
</script>



make sure you lable the link's id with what you want to pass back to main window.

DigitalBliss
04-14-2005, 10:40 PM
I really dont know anything about js, can you explain to me how to use it? I got it to where if you click a link it opens a popup with that code in it, but then what?

brandonH
04-14-2005, 10:50 PM
in the <a> tag you need to make sure that the part I told you "this.value" says this.id (no quotes).
<!-- this goes into child source code-->
<body>
<a href=#stayhere id='username1' onclick='LinkV(this.id);'>username1</a>
</body>

<script language=javascript>
function LinkV(val){
opener.document.getElementById('your text area id').value=val;
window.close();
}
</script>
<!--stop child source code>

in the above where it says: opener.document.getElementById('your text area id').value=val;

be sure the part that says 'your text area id' is the id value of the textarea or input you are using in the original document.


<!--original window source-->

<textarea id=textarea1></textarea>

<!--end original window source-->



how this works is if a window is opened by another window it is concidered to be a child window and the browser knows what window opened it. if you use opener.document.getElementById('textarea1').value='whatever' the browser know that the opener is the original window and then it goes from there with looking into the document and finding the element with the id textarea1 and then fills in the value.



hope that helps clarify it.

if not let me know

DigitalBliss
04-14-2005, 10:56 PM
THANKS A LOT! I got it to work. :D:D:D:D:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum