No announcement yet.

Java script popup

  • Filter
  • Time
  • Show
Clear All
new posts

  • Java script popup

    Hi all

    I've got some code from the web that creates a popup when a link is clicked. This works fine. But what i want is for the user to click a link in the resulting popup and the selected data be populating a form field in the original page (and for the popup to then disappear).

    Ive no idea how to search for this on google hence the post! Any ideas or links appreciated!

    Server 2000 MCP
    Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

  • #2
    Re: Java script popup

    No problemo !!
    I saw a line during my walk around the web:
    Give a person a fish, they'll eat for a day. Teach them to internet search and they'll learn a skill for a lifetime.
    All the info we need is at the end of our fingers. To take it out, that's the real pain. Anyway, back to the issue:
    Whenever you open a window from another window, the child window refers to the parent window as "opener". That means that you can populate fields in a form in the parent window from the child window by using:
    See some examples:

    Useful links:
    - Javascript Tutorial
    - Web Developer's Virtual Library
    There are a lot of sources out there. Just search for Javascript tutorials.
    Hope this info helped. Good luck.

    Sorin Solomon

    In order to succeed, your desire for success should be greater than your fear of failure.


    • #3
      Re: Java script popup

      If you want to insert elements into DOM using HTML from another window you cant use window object you need to use the opener object from root. The window object has no DOM methods applied to its object. Unless of course you prototype it.

      Example of Best Pratice:

      opener.document.getElementById('id').innerHTML=' blah blah blah'
      Its also recommended that you shy away from form.formElement.value you should rather use "document.getElementById('formElementId').valu e." Since DOM is based of elemental identifiers you should tap these powers.

      If you want to inject HTML into the other window "Probably the form" strap it to a variable var form = '<form ...'; opener.document.getElementBy('idYouWantToInjectInt o').innerHTML=form;