Multiple array values, in HTML form and select all checkboxes
| From: | Alan Lam | Date: | Fri, 23 May 2003 05:49:20 +0000 |
| Subject: | Multiple array values, in HTML form and select all checkboxes | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-9596@lists.php.net to get a copy of this message | ||
Hello Smarties,
In my html form I have assigned 3 input arrays:
<form action=foo.php name=bar>
{section name=cat_num value=$somevalues}
<input type=checkbox name=orderids[] value="{ $orders[cat_num].orderid }">
<select name=status[]>...stuff...</select>
<textarea cols=50 rows=3 name=notes[]>..stuff..</textarea>
{/section}
</form>
I would like to pass these variables into my php scripts, and update the status and note field with
the orderid as a reference.
<?php
foreach (orderids as orderid)
db_query("UPDATE $sql_tbl[table] SET status='$status[orderid]',
notes='$notes[orderid]' WHERE condition'");
?>
However it fails to work...what am I doing wrong here?
Another question I have is regarding how I can implement the following function in checking all
checkboxes:
<input type=checkbox name=orderid[] value="{ $orders[cat_num].orderid }">
<SCRIPT LANGUAGE="JavaScript">
function checkAll(field[])
{ldelim}
for (i = 0; i < field[].length; i++) field[][i].checked = true ;
{rdelim}
</script>
Now to call it I have:
<A href="javascript:checkAll(document.processproductform.orderid[];">stuff</a>
But alas it fails as well, I tried to modify the original function which only had
checkAll(field)....
What am I doing wrong?
Faithfully, always.
Alan Lam
alan@goodorient.com.cn
Web Developer
www.goodorient.com