JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 22nd, 2005, 01:55 PM
pgPHPnewbie's Avatar
pgPHPnewbie pgPHPnewbie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: france
Posts: 369 pgPHPnewbie Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 4 Days 4 h 40 m 32 sec
Reputation Power: 0
Send a message via AIM to pgPHPnewbie
passing multiple variables back to parent window

Ok I have an itme page with a popup window conaining a list of colors. After checking the colors wanted you hit add and it adds it to the text field in the parent form. Now I wanted to know if there was a way to send a hidden field to the parent field. Lets say I have the color name being sent, I would also like to send the name of the img in a hidden field for each check box. How can I get that.

Here is my script in case someone can help me do this.

Popup window:
Code:
<?php
require_once "connect.php";
?>
<html>
<head>
<title>Critter Mountain Wear ... Enjoy :P</title>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<meta name="description" content="Critter Mountain Wear - Paragliding Equipment">
<meta name="keywords" content="Critter, Critter Mountainwear, Critter Mountain Wear, Critter Harness, Harness, Competition, Competition Harness, Anarchy Pro, Anarchy, Cockpit, Instrument Container, Harnesses, Colorado Harnesses, Paragliding Harnesses, Paragliding World, Tandem Harness, Paragliding Equipment, Equipment, Product Comparision">
<link href="style.css" rel="stylesheet" type="text/css">
<script language="JavaScript"> 
<!--Begin
// Add the selected items in the parent by calling method of parent
function addToParentWin() {
var arrColours = new Array();
var allBoxes = document.body.getElementsByTagName("input");
for(var i = 0; i < allBoxes.length; i++){
 if(allBoxes.item(i).type == 'checkbox' && allBoxes.item(i).checked){
  arrColours[arrColours.length] = allBoxes.item(i).value;
 }
}

window.opener.itemsForm.colors.value=arrColours.join(", ");
window.close();
}
function changeBox(cbox) {
box = eval(cbox);
box.checked = !box.checked;
}
// End -->
</SCRIPT>
</head>

<body>

<center>
<form method='post' name='formColors'>
<table width='200' cellpadding='0' cellspacing='0' style='border: 1px solid #3f4d1e; border-bottom: 0px;'>
<tr bgcolor='#898989'>
<td align='center' valign='middle' width='200' style='border-bottom: 1px solid #3f4d1e; padding: 4px 0px;'><a class="categorie"><b> COLORS LIST </b></a></td>
</tr>

<?php
	$get = mysql_query("SELECT color, colorImg, idColor FROM critter_colors ORDER BY color ASC") or die(mysql_error());
	
	$color1 = "#dcdcdc";
	$color2 = "#eeeeee";
	$class1 = "colors2";
	$class2 = "colors1";
	
	$count=0;
	$i=0;
	while($r = mysql_fetch_array($get)){
		$color = $r['color'];
		$colorImg = $r['colorImg'];
		$idColor = $r['idColor'];
		if($row_counter & 1){
			$bg_color = $color1;
			$class = $class1;
		}else{
			$bg_color = $color2;
			$class = $class2;
		}
		$row_counter++;
		
		echo("

<tr bgcolor='$bg_color'>
<td align='left' valign='bottom' width='200' style='border-bottom: 1px solid #3f4d1e; padding: 2px 0px 2px 0px;'><a href='#' onClick=\"this.blur(),changeBox('document.formColors.choice$i');return false;\" class='$class'><img src='itemcolors/$colorImg' height='25' width='25' alt='ash' border='0'> &nbsp;<input type='checkbox' name='choice$i' value='$color'> $color </a></td>
</tr>
");
	$i++;
	}// end while loop
?>
<tr>
<td align='center' style='border-bottom: 1px solid #3f4d1e; padding: 5px 2px;'><input type='button' value='ADD COLORS' onClick='addToParentWin()' class='itemsbt'></td>
</tr>
</table>
</form>
</center><BR>


</body>
</html>


Parent window:
Code:
<?php
include "connect.php";
?>
<hmtl>
<head>
<title>Critter Mountain Wear ... Enjoy :P</title>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<meta name="description" content="Critter Mountain Wear - Paragliding Equipment">
<meta name="keywords" content="Critter, Critter Mountainwear, Critter Mountain Wear, Critter Harness, Harness, Competition, Competition Harness, Anarchy Pro, Anarchy, Cockpit, Instrument Container, Harnesses, Colorado Harnesses, Paragliding Harnesses, Paragliding World, Tandem Harness, Paragliding Equipment, Equipment, Product Comparision">
<link href="style.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
function small_window(myurl) {
var newWindow;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=300,height=450'  ;
newWindow = window.open(myurl, "Add_from_Src_to_Dest", props);
}
</script>
</head>

<body>

	<center>
	<table width='650' cellapdding='0' cellspacing='0' border='0'>
	<form method='post' action='itemsform.php?option=process' enctype='multipart/form-data' name="itemsForm">
	<tr>
	<td width='10'></td>
	<td width='190' align='left'>&nbsp;<img src='imgs/navbar_arrows.jpg' border='0'><a class='txt'> Item Colors ...</a></td>
	<td width='450' align='left'><input type='text' name='colors' size='50' class='itemsform'> <input type='button' value='Add Colors' onclick =\"javascript:small_window('itemcolors.php');\" class='itemsbt'> </td>
	</tr>
</table>
</center>

</body>
</html>


Thanks,

Nick
__________________
newton's ten laws of phisics applys here
------------------------------------------------------------

Reply With Quote
  #2  
Old September 23rd, 2005, 10:22 AM
mizzory mizzory is offline
Sencha Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: STL
Posts: 547 mizzory Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 14 h 42 m 29 sec
Reputation Power: 0
Send a message via Google Talk to mizzory
In the parent window, have a hidden field ready to accept the input from the pop up window: <input type='hidden' name='color_img'>

And now in your pop up window, right above the window.close() add a line to add text into it: window.opener.itemsForm.color_img.value=color_img.value
Now all you have to do is add a hidden field right after you display your image: <img src='itemcolors/$colorImg' height='25' width='25' alt='ash' border='0'><input type='hidden' name='color_img' value='$colorImg'>

I'm not that great at javascript but my logic says this should work, maybe with little modification.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > passing multiple variables back to parent window

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap