Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


checkbox return false???

Posted on 2007-10-04
Medium Priority
Last Modified: 2013-11-19
Need to get my head around checkboxes and the values they return, ive never really had to think about it but im writing a form script in php which places the all the post varibles into and array (in the order they are on the form) which is then pumped into my database,  i have a few check boxes which show and hide various bits of the form and which when selected return true (1) this identifys that for example, customer has a differnet billing address.

My issues arrises when i need the check box to return false, i cant really get my head around what is going wrong with my script but i cant seem to work it out.

What do checkboxes return when they are not selected?

Also whilst on the topic what are the x and y values that are posted that pop up when i create this array??

Many thanks

Question by:socross
  • 3
  • 2
LVL 28

Expert Comment

ID: 20018231
1) Checkboxes not selected are NOT submitted with the form

2) Are you using image for the submit button?
LVL 28

Expert Comment

ID: 20018256
"In addition to sending the form data, the web browser sends the x,y coordinate of where the user clicked. If the image input is not given a name then the browser sends the x and y coordinates as the "x" and "y" input fields.

If the input image does have a name, the x and y coordinates are sent using the format name.x and name.y. For example, when you click on the submit image in this form, the coordinates are sent as MySubmitImage.x and MySubmitImage.y. This feature can be used to check which image was clicked. For example, suppose you want to have an image for "Yes" and another for "No". If you name them "Yes" and "No" you can check if they clicked "Yes" by checking for the existence of the "Yes.x" field in the data that is sent."


Author Comment

ID: 20020383

So i have a couple of options,

1. work out a way to send null, if not selected. (is this possible?)

2. or add the varibles to the array if they are not set??


LVL 28

Accepted Solution

gamebits earned 1000 total points
ID: 20021983
1) you can put a hidden field with the default value BEFORE the checkbox so if the checkbox is not selected the hidden field will send the default value, if the checkbox is selected than the hidden field is ignored, both must have the same name.

Author Comment

ID: 20033206
Great stuff thanks


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question