View Full Version : Refresh Select box after pop up window closes
sharks20
10-18-2002, 09:05 PM
I was wondering if anyone can point me in the right direction on finding a script that will reload a combo box after my pop up window closes. The pop up window is where the user adds to the table that supplies the select box on my form.
Thanks for any help.
Courtney
ACJavascript
10-18-2002, 09:21 PM
You mean,, someone opens a pop up.. and that popup changes the select on the initial page.. and when they close the window it takes effect.. :D
adios
10-19-2002, 02:08 AM
Probably a good idea to 'reload' the opener's drop-down before the pop-up closes. See if this helps:
http://developer.irt.org/script/413.htm
sharks20
10-21-2002, 07:36 PM
THanks for the idea, but that's not quite what I was trying to do.
I guess I should explain a little more.
I have a pop-up window that's information to my database. When the user is finished entering the information they close the window. When the window closes it refreshes the combo box on the main page, without hitting the refresh button.
Hope this makes more sense.
Thanks
glenngv
10-22-2002, 02:46 AM
do you mean when the popup is closed, the main page will be refreshed without hitting the Refresh button?
if so, then in the popup:
if (window.opener && !window.opener.closed) window.opener.reload(); //reload main window
window.close(); //close this window
...or you want the combo box in the main window updated without refreshing the page?
sharks20
10-22-2002, 03:48 PM
yes, i want the combo box refreshed without refreshing the whole page.
glenngv
10-23-2002, 02:30 AM
in the main window:
<html>
<head>
<script language="javascript">
function addOption(txt,val){
var objSel = document.f.s;
objSel.options[objSel.options.length] = new Option(txt,val);
}
</script>
</head>
<body>
<form name="f">
<select name="s">
<option value="blah">blah</option>
</select><br>
<input type="button" value="Add item" onclick="window.open('popup.htm','popop','features')">
</form>
</body>
</html>
then in your pop up:
<html>
<head>
<script language="javascript">
function addOptionToParent(){
pwin = window.opener;
if (pwin && !pwin.closed && (typeof pwin.addOption)=="function"){
pwin.addOption(document.f.txt.value,document.f.val.value);
}
window.close();
}
</script>
</head>
<body>
<form name="f">
Enter text to add: <input name="txt"><br>
Enter value to add: <input name="val"><br>
<input type="button" value="Add to List" onclick="addOptionToParent()">
</form>
</body>
</html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.