Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Write CheckBox's back to opening window

  • 03-01-2005 9:11pm
    #1
    Registered Users, Registered Users 2 Posts: 604 ✭✭✭


    Hi guys,

    I need some help on a Javascript. I have a page that opens a popup windowwhich you can select some checkboxes. When you click Submit on the popup window i want to write the Values of the selected Checkboxes back to the Parent window into a Textbox.

    Anyone have any ideas as my Javascript skills are badly lacking.


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Does Javascript even allow you to change domain contexts like that? I thought everything was native to its own DOM...


  • Closed Accounts Posts: 304 ✭✭Zaltais


    You'll need two things:

    First you'll need 'window.opener' to pass the values back from the popup window to its parent.

    Secondly you'll need to explicitly check the 'selected' status of each checkbox, rather than just dumping the values back.

    However, using this method, there are some serious usability and accessability concerns, so I'd think twice about the way you're going about this (or at least the way it sounds like you're going about it).

    Any probs, pop up some sample code and we'll take a look.

    doodle_sketch - you can only do this when it's a popup window and when that window comes from the same site (i.e. same domain) as the parent.


  • Registered Users, Registered Users 2 Posts: 604 ✭✭✭Kai


    Well i was hoping to Draw the Checkboxes dynamically from a DB and then the ones that are selected get written back to a Text box on the Parent window with a script something like :

    function PassandClear(obj){
    alert(document.form1.chkAgent.value);
    self.opener.document.frmSearch.txtAgents.value = obj.chkAgent.value;
    //self.close;
    }

    The problem is it doesnt work, The Text box on the Parent window shows Undefined. I think the problem is that javascript obviously doesnt handle Checkbox collections the same as ASP.

    So can someone show me how to loop thru each one and write it back ?


  • Closed Accounts Posts: 304 ✭✭Zaltais


    Ok, to iterate through the list of checkboxes in a form is reasonably straightforward, but if your PassandClear function isn't working lets look at that first and resolve the problem there.

    However, unfortunately it's not very clear from your snippit if everything is going to the right places and what's happening when the form is submitted.

    For example what's passed into the 'obj' variable?

    Is there any way you can post or link to trimmed versions of the two HTML files and the javascript you're using?


  • Registered Users, Registered Users 2 Posts: 604 ✭✭✭Kai


    Tis alright thanks for the Help, i decided to not use a popup and just have it go to a new window.

    Thanks anyway.


  • Advertisement
Advertisement