Hi all,
This has got me stumped.
I am wanting to pass the values from a series of checkboxs within an IFRAME to a parent form and display the results in a text field.
This is what i habe so far:
index.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<script type="text/javascript"><!--
function chkboxVals() {
var f=document.baby;
var baseName = 'special_prod_id_';
var num = 7;
var valStr = '';
var el;
for(var i=1;i<=num;i++) {
el = f.elements[baseName+i];
if(el.checked) {
valStr += el.value+',';
}
}
var lastCharPos = valStr.length -1;
if(valStr.lastIndexOf(',') == lastCharPos) {
valStr = valStr.substring(0,lastCharPos)
}
f.result.value=valStr;
}
// -->
</script>
</head>
<body>
<FORM action="<? $PHP_SELF ?>" method="post" name="parentform" id="parentform" enctype="multipart/form-data">
<input name="prod_manf_num" type="text" style="font-size:10px">
<IFRAME SRC="specials_list.php" TITLE="Specials" WIDTH=97% HEIGHT=200 id="pframe" name="pframe" ></IFRAME>
<input type="text" name="result" size="80">
</form>
</body>
</html>
and the specials_list.php looks like:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form name="baby" method="post" action="">
<table width="100%" border="0">
<?
include ("include/dbconnect.php");
$ii = 1;
$sql = "select * from cart_products";
$sql_result = mysql_query($sql) or die ("Could not select data");
while ($row = mysql_fetch_array($sql_result)){
$prod_id = $row['prod_id'];
$prod_name = stripslashes($row['prod_name']);
?>
<tr>
<td><input name="special_prod_id_<? echo $ii ?>" type="checkbox" value="<? echo $special_prod_id; ?>" onClick="chkboxVals()"></td>
<td><? echo $prod_name; ?></td>
<td> </td>
<td>
QTY: <select name="special_qty" style="font-size:10px">
<? foreach(range(1, 12) as $count) { ?>
<option value="<? echo $count ?>"><? echo $count ?></option>
<? }; ?>
</select>
</td>
</tr>
<?
$ii++;
}
?>
</table>
</form>
</body>
</html>
I'm trying to display the results in the result text field within the parentform.
Any ideas?
Cheers,
micmac