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:
Parent window:
Thanks,
Nick
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'> <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'> <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