Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex Window Communication 3

Status
Not open for further replies.

Ritsuke

Instructor
May 14, 2002
12
0
0
US
Hello everyone - Rather large question here having to deal with communication between windows with js.

Here is the code first. (Cleaned for question)

(Parent Page)
--------------
<html>
<head>
<title>Bid Opps</title>

<script language=&quot;javascript&quot;>
function div2win() {
window.open('pop/div2.htm','divPop','width=900,height=480,scrollbars=yes');
}
</script>

</head>

<body>

<form name=bidForm>
<a href=&quot;javascript:div2win();&quot;>Division 2</a><br>
<textarea name=&quot;div2Box&quot;></textarea>
</form>

</body>
</html>

--------------

(Child Page)
--------------
<html>
<head>
<title>Division 2 Listing</title>

<script language=javascript>
function div2Value(){
window.opener.bidForm.div2Box.value = document.division2.value;
}
</script>

</head>
<body>

<form name=division2>
<input type=&quot;checkbox&quot; name=&quot;100&quot; value=&quot;100&quot;>100<br>
<input type=&quot;checkbox&quot; name=&quot;200&quot; value=&quot;200&quot;>200<br>
<input type=&quot;checkbox&quot; name=&quot;300&quot; value=&quot;300&quot;>300<br>
<input type=submit value=&quot;Submit and Close Window&quot; onClick=&quot;div2Value(); + window.close();&quot; >
</form>

</body>
</html>

--------------

Essentially the user will be able to click on a link on the Parent Page to open a new window (child page) and choose, from checkboxes, different specializations.

However, when clicking on the Submit button (child page-after choosing specializations) the Parent Window &quot;div2Box&quot; field returns with &quot;undefined&quot; in the text area.

Is there anyway for the Child Page to send back an array of data and post it into that &quot;div2Box&quot; text area on the Parent Page?

Any help would be wonderful. =)

Thank you all - Please let me know if I'm being unclear...Hopefully, I can clear it up if it seems to convoluted.
 
It is my understanding that checkboxes and radio buttons can only evaluate to true or false. To overcome can you use a drop down select box?
Code:
<html>
<head>
<title>Division 2 Listing</title>

<script language=javascript>
	
  function div2Value(){
	var bobjr = document.division2.bob.value;
    window.opener.bidForm.div2Box.value = bobjr;
	
window.close();
  }
</script>

</head>
<body>

<form name=division2>

<select name=&quot;bob&quot;>
	<option value=&quot;100&quot;>100
	<option value=&quot;200&quot;>200
	<option value=&quot;300&quot;>300
	</select>
<input type=submit value=&quot;Submit and Close Window&quot; 

onClick=&quot;div2Value();&quot; >
</form>

</body>
</html>
DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
try this on child window
<html>
<head>
<title>Division 2 Listing</title>

<script language=javascript>
function div2Value(){
for(var i=0;i<document.division2.chk.length;i++)
{
if (document.division2.chk.checked)
window.opener.bidForm.div2Box.value = window.opener.bidForm.div2Box.value + &quot; &quot; + document.division2.chk.value;
}

window.close();
}
</script>

</head>
<body>

<form name=division2>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;100&quot;>100<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;200&quot;>200<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;300&quot;>300<br>
<input type=submit value=&quot;Submit and Close Window&quot; onClick=&quot;div2Value(); &quot; >
</form>

</body>
</html>


 
&quot;Remember that amateurs built the Ark.
Professionals built the Titanic&quot;

who built stonehenge?? i would love to hire them to build my dream home 8).
 
anupamkant: I cannot seem to get that to function. =(

DeZiner: Unfortunately, the user must be able to choose multiple specializations. =( This is to save space as each division area has 100's of specializations.

Is there a way, perhaps, that each of the checkboxes could be evaluated for being true and if this is so, return the value for the 'true' checkboxes as text to the 'div2Box' textarea on the Parent Page?

So, if the user clicked on the 100 and 200 checkbox, clicked submit, the 'div2Box' would be filled with the value of 100 and 200 or 100+200.

Thank you both for taking the time to help me on this quandary. =)
 
change this if this is the only problem...
var sep=&quot;&quot;;
if (window.opener.bidForm.div2Box.value != &quot;&quot;)
sep = &quot;+&quot;
window.opener.bidForm.div2Box.value = window.opener.bidForm.div2Box.value + sep + document.division2.chk.value;


It seems that I could not get you clearly sorry... :)
 
Here is how the code is thus far. Something now appears in the &quot;div2Box&quot; - undefined+undefined+undefined :( This returns to the textarea reguardless of the checkboxes filled in and continues to fill the textarea (continues to add to itself in groups of three)

Did I some how put the code together wrong? Which is probably what has happened. :)

Thank you so much for your help so far. :)

Parent Page
------------

<html>
<head>
<title>Bid Opps</title>

<script language=&quot;javascript&quot;>
function div2win() {
window.open('pop/div2.htm','divPop','width=900,height=480,scrollbars=yes');
}
</script>

</head>

<body>

<form name=bidForm>
<a href=&quot;javascript:div2win();&quot;>Division 2</a><br>
<textarea name=&quot;div2Box&quot;></textarea>
</form>

</body>
</html>

Child Page
------------

<html>
<head>
<title>Division 2 Listing</title>

<script language=javascript>


function div2Value(){

var sep=&quot;&quot;;

for(var i=0;i<document.division2.chk.length;i++)
{
if (window.opener.bidForm.div2Box.value != &quot;&quot;)
sep = &quot;+&quot;
window.opener.bidForm.div2Box.value = window.opener.bidForm.div2Box.value + sep + document.division2.chk.value;

}

window.close();

}

</script>

</head>
<body>

<form name=division2>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;100&quot;>100<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;200&quot;>200<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;300&quot;>300<br>
<input type=submit value=&quot;Submit and Close Window&quot; onClick=&quot;div2Value(); &quot; >
</form>

</body>
</html>
 
Hi anupamkant,

In your first post you had [ignore][/ignore] in your code. This causes that from that point the text is italic and that the [ignore][/ignore] don't show up.

See the &quot;tek-tips TGML tags&quot; right below the reply window of this post

You can avoid this by enclosing your code in &#91;ignore] &#91;/ignore] tags like :

&#91;ignore]
your code
&#91;/ignore]

Just to let you know,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Ahww! That solved the problem, Bommerang! Thank you! :)

Thank you so very much, anupamkant. Your help has been phenomenal.

And DeZiner: Thank you very much for taking the time to offer an alternate solution.

You all are wonderful!

Here is the final code:

Parent
-------

<html>
<head>
<title>Bid Opps</title>

<script language=&quot;javascript&quot;>

function div2win() {
window.open('pop/div2.htm','divPop','width=900,height=480,scrollbars=yes');
document.bidForm.div2Box.value = &quot;&quot;;
}
</script>

</head>

<body>

<form name=bidForm>
<a href=&quot;javascript:div2win();&quot;>Division 2</a><br>
<textarea name=&quot;div2Box&quot;>Please Choose Specilizations</textarea>
</form>

</body>
</html>

Child
-------

<html>
<head>
<title>Division 2 Listing</title>

<script language=javascript>
function div2Value(){
for(var i=0;i<document.division2.chk.length;i++)
{
if (document.division2.chk.checked)
window.opener.bidForm.div2Box.value = window.opener.bidForm.div2Box.value + &quot; &quot; + document.division2.chk.value;
}

window.close();
}
</script>

</head>
<body>

<form name=division2>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;100&quot;>100<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;200&quot;>200<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;300&quot;>300<br>
<input type=submit value=&quot;Submit and Close Window&quot; onClick=&quot;div2Value();&quot;>
</form>

</body>
</html>

Woohoo! :)
 
Is there a possibilty to have this work in Netscape 4.7+ and Netscape 6.2+ ?
 
Thanks Erik and Ritsuke

use this for netscape
window.opener.document.getElementById('div2Box').value

and on parent use
<textarea name=&quot;div2Box&quot; id=&quot;div2Box&quot;></textarea>


working in both IE and NS.
 
First, let me thank you again for all the effort you have given towards this.

It seems to be working wonderfully in Netscape 6+ now. Unfortunately, it doesn't seem to function in Netscape 4.7+ :(

Thank you again for all the support. Here's the updated code.

PARENT PAGE
-----------

<html>
<head>
<title>Bid Opps</title>

<script language=&quot;JavaScript1.3&quot;>

function div2win() {
window.open('pop/div2.htm','divPop','width=900,height=480,scrollbars=yes');
document.bidForm.div2Box.value = &quot;&quot;;
}
</script>

</head>

<body>

<form name=bidForm method=&quot;post&quot; action=&quot;mailto:ritsuke@neowin.net&quot;>
<a href=&quot;javascript:div2win();&quot;>Division 2</a><br>
<textarea name=&quot;div2Box&quot; id=&quot;div2Box&quot;></textarea>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>

</body>
</html>

CHILD PAGE
-----------

<html>
<head>
<title>Division 2 Listing</title>

<script language=JavaScript>
function div2Value(){
for(var i=0;i<document.division2.chk.length;i++)
{
if (document.division2.chk.checked)

window.opener.document.getElementById('div2Box').value = window.opener.document.getElementById('div2Box').value + &quot; #&quot; + document.division2.chk.value;
}
window.close();
}
</script>

</head>
<body>

<form name=division2>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;100&quot;>100<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;200&quot;>200<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;300&quot;>300<br>
<input type=&quot;checkbox&quot; name=&quot;chk&quot; value=&quot;400&quot;>400<br>
<input type=submit value=&quot;Submit and Close Window&quot; onClick=&quot;div2Value(); &quot; >
</form>

</body>
</html> 'you can't depend on your judgement when your imagination is out of focus' - mark twain
'we are all in the gutter, but some of us are looking at the stars.' - oscar wilde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top