Click to See Complete Forum and Search --> : popup value
dthurman1432
06-12-2006, 05:13 PM
I currently have a popup window that is fired from a button on my form that is in a frame. The popup is another form that looks up a value for the submitter. Once the value is found I have to require the submitter to copy and paste the value back into the first form, tacky right. Is there an asp script or something that will allow the user to click a button on the popup and will pass a value back to the original form without refreshing the page that's in a frame? Refreshing causes the submitter to lose all entered data. Or is there a different method that will accomplish this?
Terrorke
06-13-2006, 02:57 AM
Yes there is a way.
It took me quite some time to figure this out, so your not alone :)
You can reference your initial screen via javascript.
Do something like this on your popup screen
self.opener.formelement.value = Somevalue
But my question with this is how do you open your popup screen?
Is it a real popup or just a new screen opened with javascript?
Because I only tested it with the command :
window.open(URL,"my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=320, height=150, top=200, left=400")
Terrorke
06-13-2006, 02:59 AM
Maybe there other ways to. But this is the way I did it.
dthurman1432
06-13-2006, 09:57 AM
I open the new window with OnClick="javascript:popUp1 ('attach.asp')" and then I have a function popUp1 that sets all the window attributes.
With the self.opener script do I set that as a button? Also what exactly does copyhistory=yes send to the new window?
Terrorke
06-15-2006, 02:54 AM
Ok this is how I did it :
On your basic page put a link (or button) :
<a href="javascript:doPopup()">Open Popup </a>
<input type=text name='field1' id='field1'>
function doPopip()
{
window.open(url,"my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=320, height=150, top=200, left=400")
}
On your popup window do your thing and to give your result back to your basic page do this :
function doPassBack(yourvalue)
{
self.opener.document.getElementById("Field1").value = yourvalue
window.close()
}
The Copyhistory=yes means you give your popup window the same history pages as your basic page. When you use the backbutton (or backspace) in your popup you get the same page as you would do it in your basic page.
Grtz
lmf232s
06-15-2006, 09:50 AM
What Terrorke showed you works just fine
BUT
while were on the subject of this i will show you 1 more thing that you can do that might come in handy from time to time.
Its pretty much the same thing that Terrorke mentioned but instead of setting an element from the popup window = the opener window, you can actually call a function on the opener window and pass in the values, then do all the horse work on the opener window.
Code on PopUp Window
<script language=javascript>
function returnselectedvalue(){
var selectedValue = document.form1.txtName.value;
opener.MyWorkHorse(selectedValue );
window.close();
}
</script>
<input type=text name=txtName value="">
<input type=button name=cmdSubmit value="Select Value" onclick="returnselectedvalue();">
Code on Main/opener window
<script language=javascript>
function MyWorkHorse(sValue){
'Now do all the work over here
document.form1.txtName.value = sValue;
}
</script>
<input type=text name=txtName value="">
Like i said its basically the same concept as Terroke mentioned but just another approach to it.
Terrorke
06-16-2006, 07:22 AM
Hi lmf232s
Like you said it's basically the same. But it's nice to see some others ways to do this
Thanx!