Jump to content

[SOLVED] Transfer data from one window to another


M.O.S. Studios

Recommended Posts

Hey guys,

Im working on a page and i need to transfer the info from a form that a user selects to another from that is already open,

 

here is the workflow

 

1.user fills out form1,

2.selets button "browse" that opens a new window with form2

3.form 2 shows a list of files in a fixed directory(s)

4.user selects desiered file,

5.window closes and places slected info into a readonly textbox

 

i dont expect to anyone to program it for me, i've programed most of it already using php and some copied javascript

 

what i need some one to show me what i have to lookup to find out how to transfer the info from window2 into window1 and how to close the window2.

 

 

thanks in advance

 

 

Link to comment
Share on other sites

Use "window.opener". Here's a quick example:

 

page1.htm

<html>
<body>

<a href="test2.htm" target="page2">Open page 2</a>

<form name="form1">
Value from page 2: <input type="text" name="page2value">
</form>

</body>
</html>

 

 

page2.htm

<html>
<head>
<script type="text/javascript">

function sendToPageOne()
{
    var thisValue = document.getElementById('page2Value').value;
    window.opener.form1.page2value.value = thisValue;
}

</script>
</head>
<body>

<form name="form2">
<select name="page2Value" id="page2Value">
   <option value="one">One</option>
    <option value="Two">Two</option>
    <option value="Three">Three</option>
</select>
</form>

<button onclick="sendToPageOne();">Send to page 1</button>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.