• 0

Change textbox in iframe from parent


Question

Hey,

Im having a bit of a problem, im trying to update the value in a texbox that is in an iframe. the updated value is coming from the normal page.

<input type="text" name="tb1">
<input type="button">

<iframe>
<input type="text" name="tb2">
</iframe>

I want to take the value in tb1 and put it in tb2 when the user presses the button.

Im still searching the net to see if i can see how to do this, but im hoping that some smart person here will already know :D

Any ideas?

Thanks in advance

Link to comment
https://www.neowin.net/forum/topic/875894-change-textbox-in-iframe-from-parent/
Share on other sites

3 answers to this question

Recommended Posts

  • 0

This can be done using javascript. I would recommend doing this when the form is submitted rather than user click on button. You could also do this when the input looses focus. If you have included jquery framework it can be done with the following code

$('input[name="tb1"]').blur(function(){

val = $(this).attr('value');

$('input[name="tb2"]').attr('value', val);

});

  • 0

Assuming you can give your input elements IDs (they were only named in your example) and that you only have one iframe, this should work.

window.frames[0].document.getElementById('tb2').value = document.getElementById('tb1').value;

And here is a jQuery equivalent, since we're on the subject.

$('iframe:first').contents().find('#tb2').val($('#tb1').val());

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Kind of an unrelated rant, but... As someone with kids, who as of a few years ago were young enough that I wanted some of these family safety features. I have to say, any good intention MS had was completely RUINED by how absolutely awful the parental interface is. There was the family portal with limited settings, but more detailed settings were scattered is completely unintuitive ways. There was a child details page where you could configure the 100+ features, but, the features in the "gaming" section only applied the extremely limited list of Windows Store games that were not XBox branded. For anything with XBox branded, you had to find the XBox parental consent portal, which had another 100+ features to dig through and try to figure out what was blocking your two kids from playing Minecraft together. To make the experience even more infuriating, MS implemented their same signature documentation we find for 365 and Azure, that it is very easy to find documents talking about how easy it is to use any given dashboard or portal, but without including a link to said resource...you might have to 20-30 results deep on Google before you find that answer, it was nearly impossible to simply find a portal by searching for it.
    • ^ Found the PR spokesperson for Apple!
    • Like many, I'm not buying and expensive items until the tariff nonsense is resolved. I wonder if that has something to do with (along with the notes others are making)?
    • Only option I want is to disable the system tray overflow menu and always show icons, W11 added option to hide the menu but then icons will still go there instead of the tray.
  • Recent Achievements

    • Week One Done
      Helen Shafer earned a badge
      Week One Done
    • First Post
      emptyother earned a badge
      First Post
    • Week One Done
      Crunchy6 earned a badge
      Week One Done
    • One Month Later
      KynanSEIT earned a badge
      One Month Later
    • One Month Later
      gowtham07 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      660
    2. 2
      ATLien_0
      269
    3. 3
      Michael Scrip
      218
    4. 4
      Steven P.
      162
    5. 5
      +FloatingFatMan
      159
  • Tell a friend

    Love Neowin? Tell a friend!