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

 

 

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.