473,585 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking For Checkbox Array

I'm working on a page for an e-commerce site that has a form than lists items in an order placed by a customer. The form serves two purposes: to edit
and save the details of the items (i.e. number of items, price, etc.) and to split the order (i.e. select certain items to remove from the order and
use to create a new separate order). Each item has a checkbox next to it, and the name for the checkbox is "name[]" so an array of the checked items
is created and passed to the processing script. The logic I want to use to determine if the items are being saved or being split out is by looking at
the $name array. However, if I try something like "if ($_POST['name'])" and none of the checkboxes are checked, I get an Undefined Index error (it
works fine if there are items checked). What is a valid way to check to see if the $name array exists so I know which action to take?

Thanks.

Steve
Jul 17 '05 #1
2 1995
Steve wrote:
What is a valid way to check to see if the $name array
exists so I know which action to take?


http://www.php.net/isset

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #2
Brion Vibber wrote:
Steve wrote:
What is a valid way to check to see if the $name array exists so I
know which action to take?

http://www.php.net/isset

-- brion vibber (brion @ pobox.com)


Duh. Brain freeze there, I guess.

Thanks.

Steve
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2121
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No...
3
1417
by: Wendy S | last post by:
I have this working, but I don't think it's done efficiently or the best way: <a href="javascript:setAllAccounts(true)">check all</a> <a href="javascript:setAllAccounts(false)">clear all</a> function setAllAccounts(value) { for(i = 0 ; i < document.forms.accounts.length; i++ ) { document.forms.accounts.checked = value; } }
4
26963
by: Piotr | last post by:
how can I read (in alert for example) array index number of checked checkbox? I have: <input type="checkbox" id="id_number" name="check" value="1" onclick="show()"/> <input type="checkbox" id="id_number" name="check" value="2" onclick="show()"/> <input type="checkbox" id="id_number" name="check" value="3"
13
31275
by: aundro | last post by:
Hello, I've been looking on the web for a solution to this problem: I create a set of checkboxes, and 2 buttons: - one is labeled "All" - the other is labeled "None" Clicking "All" is supposed to check all the checkboxes, which it does (that's not rocket science ;), but the 'onchange' event does not get triggered.
2
6621
by: Maziar Aflatoun | last post by:
Hi everyone, I am reading and displaying data rows from my database where the first column contains the Status checkbox. I like to enable my users to change the status of individual rows by checking and unchecking the checkbox column. I like to update the status in the database for the column where the status was changed. This is what...
6
1626
by: Fred Flintstone | last post by:
I have an app that requires the use of a 2 dimensional array of checkboxes. I can't seem to assign any values to them. I tried this: Dim BonusChecks(0, 0) As CheckBox ...and then later when I know the domensions I'll need: ReDim BonusChecks(x,y) ' (3,3), no error BonusChecks(0,0).ID = "1" 'Object reference not set to an instance of...
6
10396
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to group by using a two dimensional array. <form name=msgs>
0
3100
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td colspan="2"><p>
4
6600
by: uicouic | last post by:
Hi all. I need JavaScript to validate that atleast one checkbox has been checked in a form before the record(s) can be deleted. - I have an <asp:button id="btnDelete"...> and the checkbox is created via grdData_ItemDataBound with id="chkRecordId": Protected Sub grdData_ItemDataBound(ByVal sender As Object, ByVal e As...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.