Click to See Complete Forum and Search --> : Brakets Errors
melchiorus
06-05-2003, 06:35 PM
Hello, I'm new here looking for a little help.
I have a date select script in PHP and everything works except when they try and select the date they want.
The error I receive is this:
Line: 47
Char: 37
Error: Expected ']'
Code: 0
URL: http://localhost/empire/select_date.php?name=delivery[3322ffds]
And on line's 40 through 50, here is the code read from the browser:
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-14';">14</a></td>
</tr>
<tr><td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-15';">15</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-16';">16</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-17';">17</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-18';">18</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-19';">19</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-20';">20</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-21';">21</a></td>
</tr>
<tr><td class='tcell'><a href="#" onClick="window.opener.document.delivery[3322ffds].date.value='2003-06-22';">22</a></td>
I know what the problem is, it's the brakets. But I need the text field's name to be an array. Any help on this would be very useful! Thanks!
Try putting quotes inside of your brackets: ['3322ffds']
7öñä
melchiorus
06-05-2003, 10:01 PM
Well, I've tried it as the actualy name, I accidently put it there when I tried putting back everything I had changed to try and fix it. Just so you know, it doesn't work either way.
melchiorus
06-06-2003, 09:39 AM
I put the apostrophes inside the brakets like stated but not I get this error:
Line: 36
Char: 2
Error: 'window.opener.document.order.delivery.3322ffds' is null or not an object
Coce: 0
URL: http://localhost/empire/select_date.php?name=delivery['3322ffds']
As for my form code:
<form action="order.php" method="post" name="order">
<tr>
<td width="75%" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" align="left" valign="top"><?php include('menu.php'); ?></td>
<td align="center" valign="top"><?php if ($totalRows_items > 0) { // Show if recordset not empty ?>
<br>
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000">
<tr>
<td width="25"> </td>
<td bgcolor="#FFFFCC"><font color="#993300"><strong>Item Number:</strong></font></td>
<td bordercolor="#000000" bgcolor="#FFFFCC"><font color="#993300"><strong>Item Name:</strong></font></td>
<td bordercolor="#000000" bgcolor="#FFFFCC"><font color="#993300"><strong>Item Purchase Order Number:</strong></font></td>
<td bgcolor="#FFFFCC"><font color="#993300"><strong>Item Price:</strong></font></td>
<td bgcolor="#FFFFCC"><font color="#993300"><strong>Deilvery on:</strong></font></td>
</tr>
<?php do { ?>
<?php
$query_price = "SELECT price FROM prices WHERE item_id = ".$row_items['item_id'];
$price = mysql_query($query_price, $default) or die(mysql_error());
$row_price = mysql_fetch_assoc($price);
$totalRows_price = mysql_num_rows($price);
?>
<tr>
<td width="25" align="center"><input name="items[<?php echo $row_items['item_number']; ?>]" type="text" id="items[" value="0" size="5">
</td>
<td bgcolor="#FFFFCC"><font color="#000000"><?php echo $row_items['item_number']; ?></font></td>
<td bordercolor="#000000" bgcolor="#FFFFCC"><font color="#000000"><?php echo $row_items['size']; ?> <?php echo $row_items['shape']; ?> <?php echo $row_grade['name']; ?></font></td>
<td bordercolor="#000000" bgcolor="#FFFFCC"><font color="#000000"><?php echo $row_items['po_number']; ?></font></td>
<td bgcolor="#FFFFCC"><font color="#000000">$<?php echo number_format($row_price['price']); ?></font></td>
<td align="center" bgcolor="#FFFFCC"><input name="delivery[<?php echo $row_items['item_number']; ?>]" type="text" id="delivery[<?php echo $row_items['item_number']; ?>]" value="YYYY-MM-DD" size="16" maxlength="10"><br><a href="javascript:void(0)" onclick="window.open('select_date.php?name=delivery[\'<?php echo $row_items['item_number']; ?>\']','calendar','width=500,height=500,status')">Select Date</a></td>
</tr>
<?php } while ($row_items = mysql_fetch_assoc($items)); ?>
</table>
<?php } else { ?>
<p><br>
<br>
<strong>There are no items in this grade.</strong>
<?php } ?>
</p></td>
</tr>
</table>
<p> </p>
<p align="left"> </p></td>
<td align="left" valign="top"><input name="Submit" type="submit" class="order" value="ORDER"></td>
</tr>
</form>
And one more peice of code, the calendar segment's line 40-50 again:
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-14';">14</a></td>
</tr>
<tr><td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-15';">15</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-16';">16</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-17';">17</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-18';">18</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-19';">19</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-20';">20</a></td>
<td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-21';">21</a></td>
</tr>
<tr><td class='tcell'><a href="#" onClick="window.opener.document.order.delivery['3322ffds'].value='2003-06-22';">22</a></td>
melchiorus
06-06-2003, 12:36 PM
I've been researching a bit and I tried using the ID method but now I get a Expected ')' error:
print "<a href=\"#\" onClick=\"window.opener.document.getElementById('" . stripslashes($HTTP_GET_VARS['id']) . "').setAttribute('value','$y-$m-$d';\">$d</a>";
Try eval():
eval("window.opener.document.order.delivery"+"\['3322ffds'\]"+".value='2003-06-16'");
Jona
melchiorus
06-06-2003, 02:45 PM
Line: 36
Char: 2
Error: 'window.opener.document.order.delivery.3322ffds' is null or not an object
Coce: 0
URL: http://localhost/empire/select_date.php?name=delivery['3322ffds']
And here's my code:
<a href="#" onClick=eval("window.opener.document.order.delivery"+"\['3322ffds'\]"+".value='2003-06-16'");><?php echo "$d"; ?></a>
melchiorus
06-06-2003, 07:23 PM
Thanks for the help but I just gave up and went with drop down boxes. Thanks anyway, I'll keep this in mind if I ever find myself trying again.