javascript thread: Adding an option to a select box in a parent window from the child
Hi there,
I'm having problems with the above question, I'll try and explain it better
here.
I have a form on my webpage, this form has a select box in it with a few
option, if a certain option is selected then a new window is opened as a
child window.
This window has a list of values that when one is clicked should update the
option in the select box on the parent window.
Here's the code...
//in the parent window
function checkDeeds(){
if(document.form1.deeds.value=='Requested'||document.form1.deeds.value=='Rec
eived'){
MM_openBrWindow('calendar.asp?choice='+document.form1.deeds.value+'','calend
ar','width=270,height=205')}
}
--------------------------------
//in the child window
function answer(field) {
var choice = '<%=choice%>'
var n
var doc = document.forms[0];
var opendoc = opener.document.forms[0];
var cDate = new Date();
cDate.setMonth(doc.MonthField.value);
cDate.setDate(field.value);
cDate.setYear(doc.YearField.value);
var wd = cDate.getDay()-1;
var m = cDate.getMonth()+1;
var y = (bType() == "nav") ? cDate.getYear()+1900 : cDate.getYear();
var d = cDate.getDate();
var wdsITC = new Array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
if (choice=='Requested'){n=5}
if (choice=='Received'){n=4}
if (wd > 4) {
if (confirm ('You have chosen a weekend for the completion date. Are you
sure you wish to continue?')){
//opendoc.completiondate.value = wdsITC[wd] + " " + d + "/" + m +
"/" + y;
opendoc.deeds.options[(opendoc.deeds.options.length-n)]=new
Option(choice + ' ' + wdsITC[wd] + " " + d + "/" + m + "/" + y,choice + ' '
+ wdsITC[wd] + " " + d + "/" + m + "/" + y,true,true);
self.close();
}
}
else {
//opendoc.completiondate.value = wdsITC[wd] + " " + d + "/" + m +
"/" + y;
opendoc.deeds.options[(opendoc.deeds.options.length-n)]=new
Option(choice + ' ' + wdsITC[wd] + " " + d + "/" + m + "/" + y,choice + ' '
+ wdsITC[wd] + " " + d + "/" + m + "/" + y,true,true);
self.close();
}
}
Now I know it's a bit messy, but believe me it works ok if I were to use
text boxes, you can see the lines that have been commented out '//' however
with my select box it just removes the first value each time, so my list
gets smaller and smaller!
Can anyone offer any advice here?
TIA
Cheers,
Al.