mikeaag Posted February 16, 2010 Share Posted February 16, 2010 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 Share on other sites More sharing options...
0 sweetsam Posted February 16, 2010 Share Posted February 16, 2010 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); }); Link to comment Share on other sites More sharing options...
0 mikeaag Posted February 16, 2010 Author Share Posted February 16, 2010 Thanks for the reply, Im not familiar with jquery, could you give me a non jquery example please? :D Also, here's a link so you can see what im trying to achieve Link Thanks in advance Link to comment Share on other sites More sharing options...
0 Hot Posted February 17, 2010 Share Posted February 17, 2010 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()); Link to comment Share on other sites More sharing options...
Question
mikeaag
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.
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
Share on other sites
3 answers to this question
Recommended Posts