user1729894
user1729894

Reputation: 95

Copying text from IFRAME into the INPUT field on the parent page

When the visitor clicks the button after typing a text in the INPUT field which is in a framed page , is it possible to copy the typed text into the INPUT field which is on the parent page ?

iframed page code : page1.html

<form action="">
   Search:<input type="text" name="searchname"><input type="submit" value="send" size="45">
</form>

Parent page:

<IFRAME id="iframe1" src="page1.html"></IFRAME><BR>

   You searched:<INPUT type="text" id="result">

I want that the searched items display on the parent page. Thanks.

Upvotes: 0

Views: 1597

Answers (2)

HATCHA
HATCHA

Reputation: 600

In parent Create function which receive text...

function UpdateSearchNameToResult(msg){
   document.getElementById('result').value = msg;
}

In iframe Create function which send search name for submit button on "page1.html"

and call parent.UpdateSearchNameToResult(yourval);

Upvotes: 1

asdf_enel_hak
asdf_enel_hak

Reputation: 7640

According to this answer

jquery version, you can try :

$("#result").val($("#iframe1 form input[name=searchname]").val())

Upvotes: 0

Related Questions