SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    create hidden field jQuery

    Hi Guys!

    Im trying to create a hidden form field in a parent window from within a child window (popup). I am trying to use jQuery, but unfortunately the hidden field does not get created. Does anyone have an idea what could be wrong?

    Code JavaScript:
    function save_industries() {
        var namelist = [];
        with(document.select_industries) {
            for(var i = 0; i < industry.length; i++) {
                if(industry[i].checked) {
    				namelist.push(industry[i].value);
    				$('#opener.document.searchform').append('<input type="hidden" name="industry[]" value="' + industry[i].value + '">');
                }
            }
        }
        if(!namelist.length) {
            alert('Please select at least 1 industry.');
        } else {
            opener.document.getElementById('industry_list').innerHTML = "<span class=\"info\"><a href=\"#\" onclick=\"java_script:select_industries('" + namelist + "')\">Industries selected, click to edit</a></span>";
    		window.close();
        }
    }

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you sure

    Code:
    $('#opener.document.searchform')
    is selecting the form in the parent window like you want? It just looks off to me, like you copied the way you address that element in the native JS DOM into a jQuery selector?

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Zaggs View Post
    Im trying to create a hidden form field in a parent window from within a child window (popup).
    About the only success that's commonly found when doing that is for the parent window to have a function that does what you need, and to call from the child window that parent function.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •