I need to make a task where it compares an array value with an inputted text value.
For the array, the code is this:
<div class="wpsc-quantity-discounts">
<table>
<thead>
<tr>
<th class="qty" colspan="2">Quantity:</th>
<th class="curr"><span class="hidden">Currency:<span></th>
<th class="price">Price:</th>
</tr>
</thead>
<tbody>
<tr>
<td class="remove"></td>
<td class="qty">
<input type="text" size="5" value="500"/*this value*/ name="table_rate_price[quantity][]" />
+ </td>
<td class="curr">USD $</td>
<td><input class="newCurrPrice text" value="0.48" name="table_rate_price[table_price][]" /></td>
It already contains the variables I need. I need to compare the first column with an inputted text from my single product page.
<?php if(wpsc_has_multi_adding()): ?>
<fieldset><legend style="float:left;"><?php _e('Quantity', 'wpsc'); ?>: </legend>
<div class="wpsc_quantity_update">
<input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="500"/*This value*/ />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
<input type="hidden" name="wpsc_update_quantity" value="true" />
</div><!--close wpsc_quantity_update-->
</fieldset>
I need to make an if statement where if the inputted text is less than the first column's array, it will return false. If anybody has a suggestion that'd be awesome. I'm still kind of a noob in php so be easy :p. Thanks.
This is the code that I have now.
<fieldset><legend style="float:left;"><?php _e('Quantity', 'wpsc'); ?>: </legend>
<div class="wpsc_quantity_update">
<input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="500" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
</div><!--close wpsc_quantity_update-->
<php? if ( table_rate_price[1][0] > wpsc_quantity_update(value)): />
<return <input type="hidden" name="wpsc_update_quantity" value="false" />
<?php else: ?>\
return <input type="hidden" name="wpsc_update_quantity" value="true" />;
</fieldset>
Check documentation for in_array I believe that's what you are looking for.
Here is a snippet to get you started:
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}
?>
Looks like table_rate_price[1][] should be table_rate_price[1][0]? Can't tell without seeing how that array looks, do a print_r($table_rate_price) and show us the results.
I would cast value to an int or float before the comparison since all post data will be String. I'm assuming wpsc_quantity_update() returns the $_POST['wpsc_quantity_update'] value.
floatval() * decimals like 0.48, 3.14, ...
intval * whole numbers 1, 2, 3 ...
if ( table_rate_price[1][0] < floatval(wpsc_quantity_update())) {
return false;
}
return true;
Related
I have a form page and when I submit this form all inputs are posting successfully except this one:
<input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()"
<?php if($this->data['kullanici_id']){echo 'readonly';} ?>
value="<?php echo $this->data['kullanici_id']?>">
But why?
-This is my .phtml file:
<html>
<head>
</head>
<body>
<form enctype="multipart/form-data" action="/admin/kaydet" method="post" onSubmit="javascript: beforeSubmit();">
<?php if(strlen($this->data['id'])):?>
<input type="hidden" name="id" value="<?php echo $this->data['id']?>">
<?php endif;?>
<font color="green"><h3>DÜZENLE</h3></font>
<img src="/foto/<?php echo $this->data['fotograf']?>" height="110" width="110" align="left" />
<table class="table">
<tr>
<td>T.C. Kimlik No.:</td>
<td><input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" <?php if($this->data['kullanici_id']){echo 'readonly';} ?> value="<?php echo $this->data['kullanici_id']?>"></td>
</tr>
<?php if(!strlen($this->data['id'])):?>
<tr>
<td>Parola:</td>
<td><input id="password2" class="form-control" type="password" name="parola" value="<?php echo $this->data['parola']?>"></td>
</tr>
<tr>
<td>Parola Tekrar:</td>
<td><input onchange="passwordCheck(this.value)" class="form-control" type="password" name="parola" value="<?php echo $this->data['parola']?>"></td>
</tr>
<?php endif; ?>
</table>
<td><button type="submit" class="btn btn-success btn-sm glyphicon glyphicon-floppy-disk">KAYDET</button> </td>
</form>
</body>
</html>
If I have an id; page looks like an edit member page, if I haven't; page will add a new member. In id="TC" input, if I edit a member, this input shouldn't change, so I add a readonly to solve this. But when I submit, input does not post.
Sorry about my bad English :D
Reason your field is not being submitted it is because its set to readonly.
Reason for this is 'If user cannot change the field there is no point of submitting it as value will always remain the same'.
One way to mitigate this behavior is to add hidden field with same name
<input type="hidden" name="kullanici_id" value="<?php echo $this->data['kullanici_id']?>"> />
<input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" <?php if($this->data['kullanici_id']){echo 'readonly';} ?> value="<?php echo $this->data['kullanici_id']?>" />
OK so I have two different types of forms and I want to use one form to submit them both. I am using a auto-responder form for form1 fields= first, last and email. My second form is a contact me form fields= name. email and a body field. I am trying to use both these forms at one shot. I have a form that will post fields to each form (INDEX.PHP) the problem is I am not sure how to set up form one to post fields into form1 and form2 the way I want. I want to use the fields that match from form index.php to both the other forms (form1, form2). so name and email will go to both forms and the body field will go to form2. The main form will post first and last in the name field of form2....also as you can see from form 1 and 2 each form has a some sort of redirect page I need to work around.?
I have main form:
Index.php
<html>
<head>
<title>Main Form</title>
</head>
<body>
<h2>Winner Aution Item Request Form</h2>
<p><span class="error"><FONT><font color="red">* required field.</font></span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
First Name: <input type="text" name="first_name" value="<?php echo $first_name;?>">
<FONT><font color="red"> *</font>
<br>
Last Name: <input type="text" name="last_name" value="<?php echo $last_name;?>"> <FONT><font color="red"> *</font>
<br>
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
<FONT><font color="red"> *</font>
<br><br><i><b>Copy and paste auction item name below.</b></i><br>
Product Name: <input type="text" name="product_Name" rows="1" cols="10">
<?php echo $product_Name;?><FONT><font color="red"> *</font>
<input type="Submit" value="Submit" name="submit"></input>
</form>
</body>
</html>
the above form was found on a website and was pretty close to what I want it to do but not exactly....
Form1
<?php session_start(); ?>
<html>
<head>
<title>autoresponder</title>
</head>
<body>
<center>
<table cellspacing="10" bgcolor="#CCCCCC" style="border: 0px solid #000000;">
<tr><td>
<form action="http://newsletter.jeremyahenry.com//s.php" method=GET>
<strong><font color="#660000">Your First Name:</font></strong>
<input type="text" name="f" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#660000">Your Last name:</font></strong>
<input type="text" name="l" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#000066">Email address:</font></strong><br>
<input type="text" name="e" style="background-color : #FFFFFF" size=20 maxlength=50>
<input type="image" src="http://blog.jeremyahenry.com/mailermanager/images/go-button.gif" name="submit" value="Submit"><br>
<input type="hidden" name="r" value="4">
<input type="hidden" name="a" value="sub">
<input type="hidden" name="ref" value="none">
<br>
<font color="#003300">HTML: <input type="RADIO" name="h" value="1">Yes
<input type="RADIO" name="h" value="0" checked="checked">No<br>
</font>
</form>
</td></tr>
</table>
</center>
</body>
</html>
Form 2
<?php session_start(); ?>
<html>
<head>
<title>request form</title>
<style>p{font:10pt arial;}</style>
</head>
<body>
<form action="contact_me/process.php" method=post>
<table align=left border=0 height=300>
<tr>
<td nowrap>
<p> Your name:
<input maxlength=25 name=name size=25>
</td>
</tr>
<tr>
<td nowrap>
<p> Your email:
<input name=from size=25 maxlength=25>
</td>
</tr>
<tr>
<td colspan=2>
<center>
<p align=center>Enter your Auction item Name below:
<br>
<textarea cols=50 name=message rows=7></textarea>
<p align=center>
<input type=submit value="Send Message">
<input type=reset value=Reset name="reset">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
ass you can see from the code I was going to use sessions. But not to familiar with it even though I have experience with php I am still quite new to it and need help. I want to pars form data to both forms. and the product name to form two. any help on this would be greatly appreciated.. I hope this is clear enough for some one out there to help.....
Ok New code Three forms 1.main form submits information to form1 and form2.
I have set up using a session so I have: session.php
<?php
session_start();
// store session data
$_SESSION['af_first_name'] = $af_first_name;
$_SESSION['af_last_name'] = $af_last_name;
$_SESSION['af_email'] = $af_email;
$_SESSION['cf_address'] = $cf_item_name;
?>
That handles variables.
My new code for index.php
<?php
// including the session file
require_once("session_start.php")
?>
<?php
function stripZlashes($string)
{
//This function is to strip slashes for either array or a String
if (!is_array($string)) return stripslashes($string);
$nvar = array();
foreach ($string as $key => $value)
$nvar[stripslashes($key)] = stripZlashes($value);
return $nvar;
}
?>
</head>
<body>
<h2>Winner Aution Item Request Form</h2>
<p><span class="error"><FONT><font color="red">* required field.</font></span></p>
<form name="form1">
First Name: <input type="text" name="$af_first_name" id="af_first_name" value="<?php if(isset($_SESSION['af_first_name'])){echo stripslashes($_SESSION['af_first_name']); unset($_SESSION['af_first_name']); } ?>" /><br>
Last Name: <input type="text" name="$af_last_name" id="af_last_name" value="<?php if(isset($_SESSION['af_last_name'])){echo stripslashes($_SESSION['af_last_name']); unset($_SESSION['af_last_name']); } ?>" /><br>
E-Mail: <input type="text" name="$af_email" id="af_email" value="<?php if(isset($_SESSION['af_email'])){echo stripslashes($_SESSION['af_email']); unset($_SESSION['af_email']); } ?>" /><br>
</form>
<form name="form2">Copy and Paste Auction Name Below!<br>
Product Name <br><input type="text" name="$cf_item_name" id="cf_item_name" value="<?php if(isset($_SESSION['cf_item_name'])){echo stripslashes($_SESSION['cf_item_name']); unset($_SESSION['cf_item_name']); } ?>" /><br>
<input type="Submit" value="Submit" name="submit" onsubmit="form2.submit(); form3.submit();"></input>
That form takes input and sets to session. Session.php picks it up and places it in variable form. From here I used a strip for the underscores. and when it goes to form1 and form2 varables pick it up and fill in the form. Here is my new form1
<?php
function stripZlashes($string)
{
//This function is to strip slashes for either array or a String
if (!is_array($string)) return stripslashes($string);
$nvar = array();
foreach ($string as $key => $value)
$nvar[stripslashes($key)] = stripZlashes($value);
return $nvar;
}
if(!empty($_SESSION['_mf'])): //Strip all possible back slashes
stripZlashes($_SESSION['_mf']);
endif;
// including the session file
require_once("session_start.php")
?>
<center>
<table cellspacing="10" bgcolor="#CCCCCC" style="border: 0px solid #000000;"> <tr><td>
<form action="http://newsletter.jeremyahenry.com//s.php" method=GET>
<strong><font color="#660000">Your First Name:</font></strong>
<input type="text" id="$af_first_name" value="<?php echo (!empty($_SESSION['_af']['af_first_name'])?$_SESSION['_af']['af_first_name']:'') ?>" name="f" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#660000">Your Last name:</font></strong>
<input type="text" id="$af_last_name" value="<?php echo (!empty($_SESSION['_af']['af_last_name'])?$_SESSION['_af']['af_last_name']:'') ?>" name="l" style="background-color : #FFFFFF" size=11 maxlength=40><br>
<strong><font color="#000066">Email address:</font></strong><br>
<input type="text" id="$af_email" value="<?php echo (!empty($_SESSION['_af']['af_email'])?$_SESSION['_af']['af_email']:'') ?>" name="e" style="background-color : #FFFFFF" size=20 maxlength=50>
<input type="image" src="http://newsletter.jeremyahenry.com/images/go-button.gif" name="submit" value="Submit"><br>
<input type="hidden" name="r" value="4">
<input type="hidden" name="a" value="sub">
<input type="hidden" name="ref" value="none">
<br>
<font color="#003300">HTML: <input type="RADIO" name="h" value="1">Yes
<input type="RADIO" name="h" value="0" checked="checked">No<br>
</font></form>
</td></tr></table>
</center>
<?php
if(!empty($_SESSION['_mf'])):
unset($_SESSION['_mf']);
endif;
?>
form2:
<?php
function stripZlashes($string)
{
//This function is to strip slashes for either array or a String
if (!is_array($string)) return stripslashes($string);
$nvar = array();
foreach ($string as $key => $value)
$nvar[stripslashes($key)] = stripZlashes($value);
return $nvar;
}
if(!empty($_SESSION['_mf'])): //Strip all possible back slashes
stripZlashes($_SESSION['_mf']);
endif;
// including the session file
require_once("session_start.php")
?>
<form action="process.php" method=post>
<table align=left border=0 height=300>
<tr>
<td nowrap>
<p> Your name:
<input maxlength=25 name="af first name" id="af_first_name" value="<?php echo (!empty($_SESSION['_af']['af_first_name'])?$_SESSION['_af']['af_first_name']:'') ?>" size=25> />
</td</tr>
<tr>
<td nowrap>
<p> Your email:
<input name=af email id="af email" value="<?php echo (!empty($_SESSION['_af']['af_email'])?$_SESSION['_af']['af_email']:'') ?>" size=25 maxlength=25> />
</td></tr>
<tr>
<td colspan=2>
<center>
<p align=center>Enter your Auction item Name below:
<br>
<input name="cf item name" id="cf item name" value="<?php echo (!empty($_SESSION['_cf']['cf_item_name'])?$_SESSION['_cf']['cf_item_name']:'') ?>" rows="1" />
<p align=center>
<input type=submit value="Send Message">
</td></tr></table>
</form>
</center>
Ok now i have an issue with it submitting correctly...
<form name="form1">
<input type="text" value="" name="somename" onkeyup="form2.somename.value=this.value" />
</form>
<form name="form2">
<input type="text" value="" name="somename" />
</form>
check out the above code. hope this could be helpful. Or if this is not the result which you require. so you can be brief with your requirements in reply.
I don't know the usage or need of your implementation: maybe it is like a 3 step registration form?
It could be done in different ways without complicating it too much.
You could put all three forms in the same page and only showing the right one
according to th data being posted to the same page. It is the old way of doing things.
With Ajax calls, templates and javascript it could be don simpler but it depends on
your experience.
on each element you can mention as per their relevent events, such as
Ex. onkeyup="form2.elementname.value=this.value"
I have a javascript which creates two types of elements.
The PHP code is added on submiting the form, but I show it above.
The First type looks like this:
<tr class="disc">
<span><?php echo $disc_number ?></span>.
</tr>
The Second type looks like this:
<tr class="track">
<input name="trackNumbers[]" value="<?php echo $track_number ?>" />
<input name="discNumbers[]" value="<?php echo $disc_number ?>" />
</tr>
The "track" elements can be multiple for one "disc" element.
For example:
<tr class="disc">
<span>1</span>.
</tr>
<tr class="track">
<input name="trackNumbers[]" value="1" />
<input name="discNumbers[]" value="1" />
</tr>
<tr class="track">
<input name="trackNumbers[]" value="2" />
<input name="discNumbers[]" value="1" />
</tr>
<tr class="disc">
<span>2</span>.
</tr>
<tr class="track">
<input name="trackNumbers[]" value="1" />
<input name="discNumbers[]" value="2" />
</tr>
<tr class="track">
<input name="trackNumbers[]" value="2" />
<input name="discNumbers[]" value="2" />
</tr>
To show on submit each "track" element I am using "for" command.
for ($track_i = 0; $track_i < $total_tracks; $track_i++)
But what about "disc" elements? How to make my "disc" elements to also display on submit, and to have their "track" elements after them.
If I catch your meaning correctly, you need to associate the track elements with the disc numbers... so use a multi-dimensional array:
<tr class="track">
<input name="trackNumbers[<?php echo $disc_number ?>][]" value="<?php echo $track_number ?>" />
</tr>
If I recall correctly, this will produce (in PHP when submitted) an array of arrays, where each first-level array (one per disc) contains an array of tracks (one per track).
foreach($_POST['trackNumbers'] as $discNumber => $tracksArray) {
...
The way you have it setup now is you have two separate arrays track and disc, to get the track number associated to the proper disc I would set up the input element like so:
<input name="trackNumbers[1][]" value="2">
Where 1 is the disc number, you may want to pass in disc numbers once and then use them on the backend to loop through and pull out all the tracks that correspond to the disc numbers.
I have a foreach loop listing the unique codes as links:
<a href="#" class="charcoal_link" value="<?php echo $id_to ?>" style="line-height: 20px;" onclick="showMessageArea(this); return false;">
<?php echo $uniqueCode1?>
<span class="pink_text"><?php echo $uniqueCode2?></span>
<?php echo $uniqueCode3?>
</a>
<input type="hidden" name="id" value="<?php echo $id_to ?>" />
<form id="message_area" style="display:none" method="post" action="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>">
<tr>
<td>
<input name="message" type="textarea" rows="10" cols="20" value="<?php echo $message ?>" />
</td>
<td>
<input name="Submit" type="submit" value="Send" />
</td>
</tr>
</form>
the above is also in another form tag: <form name = "contacts" method="post">
the action part works fine but in messageSent.php i do:
var_dump($_POST);
var_dump($_GET);
and the output gives me:
NULL
array(1) { ["id"]=> string(2) "36" }
Where is "message"?
"id" contains the wrong id. It is not the id of the unique code I clicked on.
Your HTML is invalid. Among the many errors you have made: You can't have a form inside a table but around a tr. The browser is error correcting by moving the form element to somewhere where it is allowed, and leaving the inputs alone (since inputs can be inside td elements).
Validate. Validate. Validate.
There are so many problems with that fragment of HTML that you have shared, that you would probably benefit from a beginner's guide to authoring webpages.
<a href="#" class="charcoal_link" value="<?php echo $id_to ?>" style="line-height: 20px;" onclick="showMessageArea(this); return false;">
<?php echo $uniqueCode1?>
<span class="pink_text"><?php echo $uniqueCode2?></span>
<?php echo $uniqueCode3?>
</a>
<form id="message_area" style="display:none" method="post" action="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>">
<input type="hidden" name="id" value="<?php echo $id_to ?>" />
<table>
<tr>
<td>
<textarea name="message" rows="10" cols="20"><?php echo $message ?></textarea>
</td>
<td>
<input name="Submit" type="submit" value="Send" />
</td>
</tr>
</table>
</form>
You cannot have a form inside a form.. you must do them seperate or else in the same form....
I fixed the HTML markup for you
I am building a Codeigniter shopping cart. On the cart details page I have a form input field allowing the user to type in the quantity required of a product, and a submit button to post the information to the update function.
When there is just one item in the cart, when updating the quantity everything works as it should. However, when there is more than one item, changing the quantity of an item and clicking submit results in a ‘Undefined Offset 1: error on the following code in the Model (specifically the two lines within the array) :
function validate_update_cart()
{
$total = $this->cart->total_items();
$item = $this->input->post('rowid');
$qty = $this->input->post('qty');
for($i=0;$i < $total;$i++)
{
$data = array(
'rowid' => $item[$i],
'qty' => $qty[$i]
);
$this->cart->update($data);
}
}
This is the View code to which the above refers:
<form action="<?php echo base_url(); ?>home/update" method="post">
<div><input type="hidden" name="rowid[]" value="<?php echo $item['rowid']; ?>"/></div>
<div><input type="text" name="qty[]" value="<?php echo $item['qty']; ?>" maxlength="2" class="chg-qty"/></div>
<div><input type="submit" value="update" class="update-quantity"/></div>
</form>
And this is the Controller:
function update()
{
$this->products_model->validate_update_cart();
redirect('cart');
}
Please can anyone explain why this is happening?
Many thanks,
Matt
instead of
for($i=0;$i < $total;$i++)
use this
for($i=0;$i < count($item);$i++)
I had the same issue; I'm pretty sure the issue is in the shopping cart view
section. The hidden field isn't inside the foreach{} statement - that's why
you can edit the quantity when you have one product in your shopping cart, but
when you add another product can't edit the product. Here's a chunk of code
that worked for me.
<?php if ($this->cart->total_items()!=0) :?>
<div id="cart">
<?php if ($cart=$this->cart->contents()) :?>
<table>
<caption>Shopping Cart</caption>
<thead>
<th>Item Name</th>
<th>Option</th>
<th>Price</th>
<th>Qty</th>
<th></th>
</thead>
<?php foreach ($cart as $item): ?>
<tr>
<td><?=$item['name'];?></td>
<td>
<?php
if ($this->cart->has_options($item['rowid'])) {
foreach ($this->cart->product_options($item['rowid']) as $option => $value) {
echo $option.": <em> ".$value." </em>";
};
};
?>
</td>
<td>$<?=$item['subtotal'];?></td>
<?=form_open('index.php/shop/update_cart'); ?>
<td>
<?=form_input(array('name' => 'qty[]', 'value' => $item['qty'], 'maxlength' => '2', 'size' => '2')); ?>
</td>
<td class="remove"><?=anchor('index.php/shop/delete/'.$item['rowid'],'X','class="remove"');?></td>
<td> <?=form_hidden('rowid[]', $item['rowid']); ?></td>
</tr>
<?php endforeach;?>
<tr class="total">
<td colspan="2"> <strong>Total</strong> </td>
<td>$<?=$this->cart->total();?></td>
</tr>
<tr>
<td><?php echo form_submit('submit', 'Update your Cart'); ?></td>
<!-- When you want to empty your cart using ajax, add 'class="empty"' as a third parameter. -->
<td><?=anchor('index.php/shop/empty_cart', 'Empty Cart', 'class="empty"');?></td>
<?=form_close();?>
</tr>
</table>
<?php endif;?>
</div>
<?php endif;?>
I believe that your problem is that you need to have
<form action="<?php echo base_url(); ?>home/update" method="post">
<div><input type="hidden" name="rowid[]" value="<?php echo $item['rowid']; ?>"/></div>
<div><input type="hidden" name="rowid[]" value="<?php echo $item['rowid']; ?>"/></div>
<div><input type="text" name="qty[]" value="<?php echo $item['qty']; ?>" maxlength="2" class="chg-qty"/></div>
<div><input type="text" name="qty[]" value="<?php echo $item['qty']; ?>" maxlength="2" class="chg-qty"/></div>
<div><input type="submit" value="update" class="update-quantity"/></div>
</form>
Namely, the 2 entries for the rowid and qty.
This link provides examples of using both standard and associative arrays with HTML inputs.
EDIT based on OP feedback:
This was the example I was referring too:
<label><input type="checkbox" name="choice[]" value="1"/> 1</label>
<label><input type="checkbox" name="choice[]" value="2"/> 2</label>
<!-- etc... -->
// meanwhile, on the server...
$choice = $this->input->post('choice');
print_r($choice); // Array ( [0] => 1 [1] => 2 );
Another example:
<form method="post" action="">
<input maxlength="30" name="friend[]" size="30" type="text" />
<input maxlength="30" name="friend[]" size="30" type="text" />
<input maxlength="30" name="friend[]" size="30" type="text" />
<input type="submit" value="Submit" />
</form>
// ***** Server-Side PHP: *****
// Loop through the friend array
foreach ($_POST['friend'] as $value) {
if ($value) { echo $value."<br />"; }
}
Notice where the examples are using an input with the same "blah[]" for each value they expect to come back in the array. In your code, you have one rowid[] and one qty[] input in your view. For a single element this will work b/c you have one element defined in the array. when you have 2 items and you apparently are updating the total items variable to represent the correct number of items but then loop through trying to access the second element (i.e. 1) in each array which does not exist which is why you're getting "Undefined Offset 1" error.