...

View Full Version : Passing parent's select to child's form



zoobie
10-05-2003, 03:07 AM
I need to make a select in a parent's form exactly like a select in a child's form onchange.
See the post below...I think I'm close.
Thanks

firepages
10-05-2003, 05:07 AM
Hi , you can do this via javascript so I am moving you to that forum.

zoobie
10-05-2003, 05:54 AM
Ok...
I've put the exact same select dropdown into the child's form
with a style="display:none" which seems to work.
The one in bold is for the child but not working at all.
Maybe I have them backward or there's a better way.
Fix? Thanks


window.onload = function(){
document.sara.sty.onchange = function(){
comments.document.forms[0].sam.className=this.options[this.selectedIndex].value;
comments.document.forms[0].sty.options[document.selectedIndex].value=this.options[this.selectedIndex].value;
}
}

zoobie
10-11-2003, 06:53 AM
Ha ha! I go to Las Vegas for a week and this still hasn't been answered...Oh well, I turn it around then. Thanks :rolleyes:

Kor
10-11-2003, 10:36 AM
try

comments.document.forms[0].sty.options[document.forms[0].sty.selectedIndex]value= ....

glenngv
10-11-2003, 11:37 AM
What you were trying to do was set the select's value not its selectedIndex...

If both selects have the same option items in the same order,
just set the parent select's selectedIndex to the current select's.


window.onload = function(){
document.sara.sty.onchange = function(){
var parentForm = comments.document.forms[0];
parentForm.sam.className=this.options[this.selectedIndex].value;
parentForm.sty.selectedIndex=this.selectedIndex
}
}

If not, you need to search for it:


window.onload = function(){
document.sara.sty.onchange = function(){
var parentForm = comments.document.forms[0];
parentForm.sam.className=this.options[this.selectedIndex].value;
var parentSelect = parentForm.sty;
var searchString = this.options[this.selectedIndex].value;
for (var i=0;i<parentSelect.options.length;i++){
if (parentSelect.options[i].value==searchString){
parentSelect.selectedIndex=i;
break;
}
}
}
}

zoobie
10-11-2003, 09:16 PM
Exactly...Thanks. :p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum