/    Sign up×
Community /Pin to ProfileBookmark

Passing values from one page to another

Hello all,

I’m trying to send some text from one page to another page that is already open. I found an example that does this but it opens up a new page every time.

///Main Page
<HTML>
<Head>
<Script Language=JavaScript>

xferWindow = “”;
tmpVal = 0;

function xferValue(){

xferWindow.document.getElementById(‘xferArea’).value = tmpVal;
}

function getValue(){

tmpVal = document.getElementById(‘origArea’).value;
xferWindow = window.open(‘TAWindow.html’);
xferWindow.opener = self;
}

</Script>
</Head>
<Body>
<center>
<h3></h3>
<form name=’nameInput’>
<form>
<textarea cols=”40″ rows=”4″ id=”origArea”>
</textarea>
</form>
<br>
<input type=’button’ value=’Show Text in New Window Text Area’ onClick=”getValue()”>
</center>
</body>
</html>

//Called Page
<HTML>
<Body>
<form>
<textarea cols=”40″ rows=”4″ id=”xferArea”>
</textarea>
</form>
<Script Language=JavaScript>
opener.xferValue();
</Script>
</Body>
</HTML>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JAug 18.2004 — Please try the following in your main page



<Script Language=JavaScript>

xferWindow = null

tmpVal = 0;

function xferValue(){

if(xferWindow){

xferWindow.document.getElementById('xferArea').value = tmpVal;

}

}

function getValue(){

tmpVal = document.getElementById('origArea').value;

xferWindow = window.open('TAWindow.html');

}

</Script>
Copy linkTweet thisAlerts:
@vitopauthorAug 20.2004 — Put your code in but new pages continue to open each time I hit the submit button.
Copy linkTweet thisAlerts:
@javaNoobieAug 20.2004 — you will have to check if it is already opened. if it is not opened, open another window.
<i>
</i>if(xferWindow!=null &amp;&amp; xferWindow.close){
xferWindow = window.open('TAWindow.html');
}
Copy linkTweet thisAlerts:
@williamhongAug 20.2004 — check out this one:

///Main Page

<HTML>

<Head>

<Script Language=JavaScript>

xferWindow = "";

tmpVal = 0;

function xferValue(){

xferWindow.document.getElementById('xferArea').value = tmpVal;

}

function getValue(){

tmpVal = document.getElementById('origArea').value;

xferWindow = window.open('TAWindow.html','samewindow');

xferWindow.opener = self;

}

</Script>

</Head>

<Body>

<center>

<h3></h3>

<form name='nameInput'>

<form>

<textarea cols="40" rows="4" id="origArea">

</textarea>

</form>

<br>

<input type='button' value='Show Text in New Window Text Area' onClick="getValue()">

</center>

</body>

</html>

//Called Page

<HTML>

<Body>

<form>

<textarea cols="40" rows="4" id="xferArea">

</textarea>

</form>

<Script Language=JavaScript>

opener.xferValue();

</Script>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@Mr_JAug 20.2004 — Please try the following

// Main Page

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>

<Script Language=JavaScript>

xferWindow = null

function xferValue(){

xferWindow.document.getElementById('xferArea').value = tmpVal;

}

function getValue(){

tmpVal = document.getElementById('origArea').value;

if(!xferWindow){

xferWindow = window.open('TAWindow.html');

xferValue()

}

else{

xferValue()

}

}

</Script>

</HEAD>

<BODY>

<center>

<h3></h3>

<form name='nameInput'>

<form>

<textarea cols="40" rows="4" id="origArea">

</textarea>

</form>

<br>

<input type='button' value='Show Text in New Window Text Area' onClick="getValue()">

</center>

</BODY>

</HTML>

// Called Page

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>

</HEAD>

<BODY>

<form>

<textarea cols="40" rows="4" id="xferArea">

</textarea>

</form>

</BODY>

</HTML>
×

Success!

Help @vitop spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...