ccurle
12-07-2006, 09:00 PM
I have a form that is a pop up window, and when you fill it out, the variables get sent to a javascript function in the parent window.
I put in the alert box to see if the variables were passing, and they were, and then I discovered that after I click the OK button in the alert box, the script works, if I take it out it doesn't work. Could there be a timing issue or something I am not doing right?
I don't understand why it works with an alert box, but not without.
Here is the code for the pop up
var newCat = null;
function addCat() {
if (newCat && !newCat.closed) newCat.close();
newCat = open('admin_create_category.php','newCat','left=300,top=85,width=350,height=270,status=0');
}
Here is the code in the pop up window
function setOpener(oForm) {
if (opener && !opener.closed) {
var newChanName = oForm.chanName.value;
var newChanDesc = oForm.chanDesc.value;
opener.addCategory('channelResult',newChanName,newChanDesc);
self.close();
return false;
}
}
Here is the function in the parent window that sends to php page
function addCategory(div_id,cn,cd) {
subject_id = div_id;
var channelID = document.program.Channel[document.program.Channel.selectedIndex].value;
var addURL = "admin_create_category_result.php?ChanName=" + escape(cn) + "&ChanDesc=" + escape(cd) + "&ChannelGK=" + escape(channelID);
alert("You have added " + cn + " to the category list");
http.open("GET", addURL, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
Thanks in advance
I put in the alert box to see if the variables were passing, and they were, and then I discovered that after I click the OK button in the alert box, the script works, if I take it out it doesn't work. Could there be a timing issue or something I am not doing right?
I don't understand why it works with an alert box, but not without.
Here is the code for the pop up
var newCat = null;
function addCat() {
if (newCat && !newCat.closed) newCat.close();
newCat = open('admin_create_category.php','newCat','left=300,top=85,width=350,height=270,status=0');
}
Here is the code in the pop up window
function setOpener(oForm) {
if (opener && !opener.closed) {
var newChanName = oForm.chanName.value;
var newChanDesc = oForm.chanDesc.value;
opener.addCategory('channelResult',newChanName,newChanDesc);
self.close();
return false;
}
}
Here is the function in the parent window that sends to php page
function addCategory(div_id,cn,cd) {
subject_id = div_id;
var channelID = document.program.Channel[document.program.Channel.selectedIndex].value;
var addURL = "admin_create_category_result.php?ChanName=" + escape(cn) + "&ChanDesc=" + escape(cd) + "&ChannelGK=" + escape(channelID);
alert("You have added " + cn + " to the category list");
http.open("GET", addURL, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
Thanks in advance