Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2005
    Location
    Gozo -Malta
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I pass a parameter from a function to a pop-up window?

    Hi all,

    I'm using a function to open a pop-up window in which the user is asked to fill in a form. I need to set the value of one of the text fields in the form to reflect the place from where the function was called.

    I'm using this code to open the pop-up window:

    function openpopup2(popurl,hsename){
    var winpops=window.open(popurl,"","width=500,height=420 scrollbars=Yes")
    }

    I want to put the value of hsename in one of the text fields!!!

    How can I do this? Any ideas please?

    Regards,
    ilmus

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    There are quite a few ways of transfering data to a popup, one way is


    function openpopup2(popurl,hsename){
    winpops=window.open(popurl,"","width=500,height=420 scrollbars=Yes")

    winpops.document.formName.ElementName.value=hsename

    }

    but the loading of the popup might not load quick enough before the value is sent

    Another way would be to have the popup get the value from the opener when it has loaded


    function openpopup2(popurl,hsename){
    winpops=window.open(popurl,"","width=500,height=420 scrollbars=Yes")

    transferValue=hsename

    }

    Then in the popups opening body tag

    onload="document.formName.ElementName.value=opener.transferValue"

    Or you can go down the QueryString route
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #4
    New Coder
    Join Date
    Jan 2005
    Location
    Gozo -Malta
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks for your time guys. Mr J's solution worked out nicely.

    Regards,

    ilmus


  •  

    Posting Permissions

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