Page 1 of 1

Javascript technique to retrieve checked values...

Posted: Thu Oct 31, 2002 5:44 am
by rlogin
Hi all,
I wanted some help on this scenario...
I have a main browser window. On clicking a hyperlink, i popup a new window. The pop up window has several check boxes and a submit buton.
The user is expected to check some of the boxes and submit.
These checked values need to be populated in a text box in the main window and the popup should close down.

Iam not able to get the checked values in the popup window into the main window check box.

Can somebody gimme some rough code or an approach to get over this...
Rgds

Posted: Thu Oct 31, 2002 6:57 am
by gOloVasTicK
Try this:

In main window:
<a href=your_popup.html target=_blank>ypur_link</a>
<form name=frm>
<input type=text name=txt>
</form>

In popup window:
<form name=popupf>
<input type=checkbox name=chbx1 value=1>
<input type=checkbox name=chbx2 value=2>
<input type=checkbox name=chbx3 value=3>
<input type=button value=submit onClick='for(i=1;i<4;i++){if(eval("popupf.chbx"+i+".checked")){opener.document.frm.txt.value+=eval("popupf.chbx"+i+".value")+";"}};window.close();'>
</form>

Rgdz

Posted: Thu Oct 31, 2002 7:07 am
by gOloVasTicK
If you want get checkboxes values in main window checkbox:

In main window:
<a href=your_popup.html target=_blank>your_link</a>
<form name=frm>
<input type=checkbox name=chbx1>
<input type=checkbox name=chbx2>
<input type=checkbox name=chbx3>
</form>

In popup window:
<form name=popupf>
<input type=checkbox name=chbx1 value=1>
<input type=checkbox name=chbx2 value=2>
<input type=checkbox name=chbx3 value=3>
<input type=button value=submit onClick='for(i=1;i<4;i++){eval("opener.document.frm.chbx"+i+".value=popupf.chbx"+i+".value")}};window.close();'>
</form>

Rgdz