SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating a form field using popup window

    I am created a site where personal messages will be sent to other members. To do this I want to allow users to either type in the users seperating their name by ; (ie Joe Bloggs; Michael Jackson; Fred Flintstone). or alternativly have a popup box where all the names on the database are displayed in a list with a check box next to the names. I will be using PHP to interact with the database and know about this

    My problem is getting details from the popup box and displaying them in the text field on the main browsers form? So if in the popup box the user checked Michael Jackson's name how would I get Michael Jackson to dispaly in the main browers field (input name ="to")?

    Does anyone know how to do this?

    Thankyou
    Eternity

  2. #2
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Easy way is to depend on IE's dialogArguments as described here: http://www.webreference.com/js/column90/9.html
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will need to modify this obviously, but this should give you what you need.
    Code:
    <a href='#' onClick="window.opener.document.frm.txt.value='hi';">link</a>
    So if you had a link in your pop-up with this onClick code it would change the text of a text input named txt in the parent window.

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  4. #4
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vasudevelopa
    You will need to modify this obviously, but this should give you what you need.
    Code:
     
    <a href="#" onClick="window.opener.document.frm.txt.value='hi';">link</a>
    So if you had a link in your pop-up with this onClick code it would change the text of a text input named txt in the parent window.

    Excellant! Thankyou.
    Is this cross browser though. For some ilogical reason, people using the site may be tempted to use netscape...
    Eternity

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kjc
    Is this cross browser though. For some ilogical reason, people using the site may be tempted to use netscape...
    Works in NS && IE for Mac.

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    That code snippet should work in any browser released in the past seven or so years (at least, javascript-supported browsers!).

  7. #7
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    That code snippet should work in any browser released in the past seven or so years (at least, javascript-supported browsers!).
    Thankyou. Is there anyway I can add content to data already in the input field?
    Eternity

  8. #8
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kjc
    Thankyou. Is there anyway I can add content to data already in the input field?

    Ok i figured it out - pretty easy.

    <a href="#" onClick="window.opener.document.sendpm.cc.value+='<?echo "$username; ";?>';">To</a>

    Another query though. On the pop up window I have a large page which scrolls down. It someone clicks on the above code to update the main browser window, the popup window jumps to the top of the page meaning the user will then have to scroll back down. Is they anyway to stop the popupwindow from moving to top of the page again?

    kjc
    Eternity

  9. #9
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could add an anchor tag <a name=foo> and change the href of that link to href=#foo.

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.


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
  •