/    Sign up×
Community /Pin to ProfileBookmark

odd problem passing from child to parent

I’m familiar with passing text and radio values from parent/child and vice-versa.

I have a parent form…opens child…multiple select drop down box appears with 5 states…choose any 3 for example and to check I have the choices fill in a table on the child just to be sure…OK, this all works. Here’s my problem: I can’t seem to pass the values selected in the child back to the parent. Partial child code is:


*****************

THIS PART TAKES THE MULTIPLE SELECTIONS AND MAPS THEM


******************

function States5Year() {

if (document.childForm1.select1.options[0].selected)
document.childForm1.state1.value=document.childForm1.select1.options[0].value;

if (document.childForm1.select1.options[1].selected)
document.childForm1.state2.value=document.childForm1.select1.options[1].value;

if (document.childForm1.select1.options[2].selected)
document.childForm1.state3.value=document.childForm1.select1.options[2].value;

if (document.childForm1.select1.options[3].selected)
document.childForm1.state4.value=document.childForm1.select1.options[3].value;

if (document.childForm1.select1.options[4].selected)
document.childForm1.state5.value=document.childForm1.select1.options[4].value;

}


********************

THIS IS SUPPOSED TO TAKE BACK
TO PARENT VALUES FROM CHILD


*********************

function updateParent(childForm1) {

opener.document.forms[0].state1.value = document.childForm1.state1.value;
opener.document.forms[0].state2.value = document.childForm1.state2.value;
opener.document.forms[0].state3.value = document.childForm1.state3.value;
opener.document.forms[0].state4.value = document.childForm1.state4.value;
opener.document.forms[0].state5.value = document.childForm1.state5.value;

self.close();
return false;

The 1st part works, its the second part that has me up a tree. Thoughts or suggestions please.

Thanks,
Ron

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@requestcodeNov 19.2003 — Try removing the childForm1 variable from your function statement like this:

function updateParent() {

....

}

It is not needed and might be causing a conflict.
Copy linkTweet thisAlerts:
@rjusaauthorNov 19.2003 — hey OF,

thanks...tried taking out the childForm1 reference...no dice. This is rather peculiar...since I put the table in the child to check results I know the selections are being captured but I can't pass them...hmmm... I took out the drop down and filled in states in the text boxes the drop down would normally fill in and they do get passed back to the parent! So I guess my starting point tomorrow will be to try and figure out why the selections are being captured 'options[0], [1], etc'., mapped 'state1, state2, etc' and reported correctly in the child but not passed back to the parent...the fact that the non-dropdown technique works maybe should provide some hint but I'm admitedly lost and frustrated. Thanks again.

Ron
Copy linkTweet thisAlerts:
@rjusaauthorNov 19.2003 — don't know if this helps any but after I select the states in drop down and click the "States" button, the selections are posted in the little table below the drop down (sort of my check)...so far so good...HOWEVER, when I click the "Update" button, the selections from the drop down AND the table below are cleared and I'm still in the child.
×

Success!

Help @rjusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...