Iframe Href link w/ onclick to change value of parent document textbox

Discussion in 'Programming' started by BRIAN_C_C, Sep 23, 2007.

  1. #1
    I need to know how i can make an hyperlink inside an iframe change the value of a textbox in a form on the parent document containing that iframe. I have no problem with:

    I've tried something like

    <a onClick="document.form.textbox.value='my value here';return false" href="##> Link here </a>

    to change the value of the textbox when the form was inside the same document as the code... but I'm having trouble getting that code to reach out of the iframe and change it's parent....

    THanks a mill for any speedy responses!!!
     
    BRIAN_C_C, Sep 23, 2007 IP
  2. CygnetGames

    CygnetGames Peon

    Messages:
    43
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try adding target="_parent" to your link, like this:
    
    <a target="_parent" onClick="document.form.textbox.value='my value here';return false" href="##> Link here </a>
    
    Code (markup):
    Not sure if this will work, but it's worth a try.
     
    CygnetGames, Sep 24, 2007 IP
  3. MetaCipher

    MetaCipher Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can grab the parent element by using the parent object:

    window.parent.form.textbox.value =
     
    MetaCipher, Sep 24, 2007 IP
  4. BRIAN_C_C

    BRIAN_C_C Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4

    You're awesome!! thank you!!!!:)
     
    BRIAN_C_C, Sep 24, 2007 IP
  5. BRIAN_C_C

    BRIAN_C_C Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Is their a way to make the value equal the text content following it...

    here's what i need

    <a Target=_parent onClick="window.parent.form.textbox.value='get following text here'; return false" href=dining.html#city>This text becomes the value</a>
     
    BRIAN_C_C, Sep 24, 2007 IP
  6. MetaCipher

    MetaCipher Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I am not sure what you mean. You want the text between the <a> tags to be the text to be put in the textarea? If so:

    <a Target=_parent onClick="window.parent.form.textbox.value= this.innerHTML; return false" href=dining.html#city>This text becomes the value</a>
     
    MetaCipher, Sep 26, 2007 IP
  7. BRIAN_C_C

    BRIAN_C_C Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    That was perfect!! tHANK YOU!!!

     
    BRIAN_C_C, Sep 27, 2007 IP
  8. MetaCipher

    MetaCipher Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    No problem.
     
    MetaCipher, Sep 27, 2007 IP