/    Sign up×
Community /Pin to ProfileBookmark

passing the values of a mulitiple checkboxes on a child form back to a parent form

I’m trying to send the values of selected checkboxes from a popup form back to it’s parent window.

I launched a modal popup window which forces the user to interact with that window then send the info back to the field that i want to populate.

However it does not send the info back. i’m really at a loss here as to why this last step is not working.

===================================
These are the functions on the Parent window.

[COLOR=blue] function myReasonDialog(){

var myReason;
}

function openReasonPickerDialog(wnd, change, dlgURL)
{
myReasonDialog.myReason=” “;
if(wnd.showModalDialog(
dlgURL,
myReasonDialog,
“dialogHeight:190px;dialogWidth:200px;”)
== true )
{

change.value = myReasonDialog.myReason;

}

else

{
return;
}

}

[/COLOR]
==============================================

This is the function on the child window:

[COLOR=blue]
function sendAndClose( reason, vType){
var fld = window.document.forms[0].reason;
thevalue = ” “;
sep= ” “;
hits = 0;
if (vType == “checkbox”) {
if (reason.value == null) {
for (i =0; i < reason.length; i ++)
{
if ( reason[i].checked) {
hits++
if (hits > 1) {
sep = ” , ” ;
}
thevalue += sep + reason[i].value;
{
window.dialogArguments.myReason =
thevalue.value;
window.returnValue=true;
window.close();
}
}
}
}
}
}

[/COLOR]
============================================

This is the code that is attached to a button that is supposed to send the data back to the parent form.

sendAndClose(this.form.reason);

=============================================

I’m fairly new to javascript so I would appreciate it if anyone could tell me why when I click on the ok button on the popup window, nothing happens.

I was able to make it work using similar code with a select object.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@oleragMar 04.2004 — This [URL=http://forums.webdeveloper.com/showthread.php?s=&threadid=29303]thread[/URL] provides a scenario where

one radio group value (with two buttons) returns info back

to the parent. You'll need to alter things a bit but the

concept is the same.

In the thread sample, it uses a static popup so if you

generating the popup html from the parent, you'll also need

to do some further editing, but not much.
Copy linkTweet thisAlerts:
@lapexterauthorMar 04.2004 — Olerag;

Thanks for responding.

I'm using a "modal" window property so that I could force the user to interact with the popup.

I've been able to pass the results to a field on the popup form, but not back to the temporary variable that comes over from the parent form.

I am fairly new to Javascript development, so i'm not sure if i may have missed something in the code that I provided.
Copy linkTweet thisAlerts:
@oleragMar 04.2004 — The previously referenced thread performs the precise

requirement you ask for. It, the passRadioValue() function

in the popup page, passess (using the window.opener

function) either a "Y" or "N" to the parent's setHidden()

function. The passed value could just as easily have been

an instantiated variable or form object value.

In your case, you would probably pass the checkbox value(s)

to a function in the parent form. You can also, if preferred

(using the "parent" object) directly assign form object values

in the parent from a child. I personally prefer using the

window.opener technique.
Copy linkTweet thisAlerts:
@KorMar 05.2004 — So... you want to fire a function written in "parent"? Use

window.opemer reference.

As far as I can see, your second function sends nothing and fires nothing from child to opener, as there is no window.opener reference there

here's an example in attachment

[upl-file uuid=8f958a01-bbcc-4aec-a647-b69b2b399fc5 size=582B]ex.zip[/upl-file]
Copy linkTweet thisAlerts:
@lapexterauthorMar 05.2004 — Thanks for the pointers guys.

Kor;

In the first function that is on the parent form, I have a variable called "var myReason" my idea was to use that as a container to hold the check box values from the child form.

Because the child form is modal, it seems that precludes me form using window.opener and setting the values on the parent that way. Of this i'm not 100% sure as I am feeling my way on this.

"change" is the field on the parent form that is supposed to get the values from the child.

As olerag stated, I'm trying to passs the valu back to a function on the parent form which in turn passes it to the field.
Copy linkTweet thisAlerts:
@oleragMar 05.2004 — Once again I will mention that the thread reference in my

first post seems to perform the requirement you ask for.

Have you opened that thread, c&p the code, and ran it yet??
Copy linkTweet thisAlerts:
@lapexterauthorMar 05.2004 — I'm making the necessary adjustments to your example as I type.

I'll let you know how it works out.

I was trying to work with mine to see what I missed in what i did.
×

Success!

Help @lapexter 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...