473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Concatenating checkbox values before post?

Is it possible to concatenate the values of 12 checkboxes into one value (separated by pipes)?

Box1 value|Box2 value |box3 value | ...etc


Thank you in advance for any help

Greg
Sep 18 '07 #1
7 3865
pbmods
5,821 Expert 4TB
Heya, Greg.

Try naming each checkbox using brackets:
Expand|Select|Wrap|Line Numbers
  1. <input name="option[]" ... /> Option 1
  2. <input name="option[]" ... /> Option 2
  3. <input name="option[]" ... /> Option 3
  4. <input name="option[]" ... /> Option 4
  5.  
This will create an array on the PHP side ~_^
Sep 18 '07 #2
Heya, Greg.

Try naming each checkbox using brackets:
Expand|Select|Wrap|Line Numbers
  1. <input name="option[]" ... /> Option 1
  2. <input name="option[]" ... /> Option 2
  3. <input name="option[]" ... /> Option 3
  4. <input name="option[]" ... /> Option 4
  5.  
This will create an array on the PHP side ~_^

Sorry I am a newbie...what do I do next with this? I need the checkbox values to be placed into a single field that I can post to Paypal without having an intermediate php page.

Thanks in advance for any help

Greg
Sep 26 '07 #3
acoder
16,027 Expert Mod 8TB
Sorry I am a newbie...what do I do next with this? I need the checkbox values to be placed into a single field that I can post to Paypal without having an intermediate php page.
What format does PayPal require it to be in?
Sep 26 '07 #4
Paypal allows up to 10 user defined fields (USER1, USER2, etc) These are stored then posted back to the site who submitted the data for payment processing.....I can then write them to the database.

I just need a variable called "USER4" that contains the selected checkbox data...ideally separated by pipes ("|"). So if the checkbox choices were:

checkbox1 value="Monday"
checkbox2 value="Tuesday"
checkbox3 value="Wednesday"
checkbox4 value="Thursday"

and the user checked "Monday" and Wednesday"....the field "USER4" would contain:

"Monday||Wednesday"


The key here is that I need to get the concatenated value BEFORE posting....so using the implode function in PHP won't work.

Any help is appreciated...this is the LAST thing I need to get working before finishing a project that was truthfully beyond my skill level :)

Thanks
Greg
Sep 26 '07 #5
acoder
16,027 Expert Mod 8TB
Is it necessary to use checkboxes for this? You could use a multiple select.

Anyway, loop over the checkboxes and check the checked property of each checkbox, e.g.
Expand|Select|Wrap|Line Numbers
  1. var checkboxes = document.getElementsByName("checkboxname");
  2. for (i = 0; i < checkboxes.length; i++) {
  3.   if (checkboxes[i].checked) {
  4.   //concatenate
  5.   }
  6. }
Sep 26 '07 #6
Thanks for the tip..I will give it a try

I think I need to use checkboxes because the actual number of checkboxes is 12 and I need to limit the actual number of checkboxes selected to 5.......would I be able to do that with multi select?


Greg
Sep 26 '07 #7
acoder
16,027 Expert Mod 8TB
I think I need to use checkboxes because the actual number of checkboxes is 12 and I need to limit the actual number of checkboxes selected to 5.......would I be able to do that with multi select?
You could do, but you will need to add a bit of Javascript checking onchange.
Sep 26 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Angelos | last post by:
I have this list of logs stored in a MySQL DB. I display them in a list and next to each log I have a del view LINK I want to add Checkboxes next to each log and keep del and view links as...
0
by: Petrucci2000 | last post by:
I have written custom installer class with my setup proj. I was wondering how do I extract checkbox values from the user interface (I have added an extra user interface dialog with a checkbox). ...
1
by: hazz | last post by:
What do I do to capture the checkbox values as listed below in order to update the database table. There will be an ID field also contained in the row to use in the update query. What would I put...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
10
by: LionsDome | last post by:
Hello, I have a vb.net page which a bunch of checkboxes. A user can select a checkbox(s) and hit the submit button to store those values in a SQL Server table. This works fine with no problem...
22
by: Mike1961 | last post by:
Checkbox values Hello. I have a problem with this code ASP / Javascript. The problem is JavaScript; try this LINK and select value cespiti 1) With ASP language is populated a secondary...
9
by: raamay | last post by:
I have six checkboxes as shown below: <table> <tr> <td><input name="spec1" type="checkbox" value="0" tabindex="11" /><label id="label">Bridge Construction</label></td> </tr> <tr> <td><input...
1
by: JSharma | last post by:
Hii Everyone I am having a problem while inserting the checkbox values into database after posting. I am actually getting the Checkbox fields from Database .Now I want to insert the Checked field...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.