473,385 Members | 1,764 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,385 software developers and data experts.

How do I add the values of an array

2
I have php code that I am using on submit of a registration form that passes the number of checked "check boxes" counted for each array to a shopping cart as a product quantity.
I want to modify that code to pass the value of "input textboxes" (for products where more than one can be purchased) for another array. right now no matter if 3 or 4 or 2 is typed into the form only 1 is being passed to the shopping cart.
This is what works using check boxes. What should I change to use text input boxes?
Expand|Select|Wrap|Line Numbers
  1. $debug = false;
  2. $bqtyd_array = $bqtyw_array = $fqtyd_array = $fqtyw_array = $tentm_array = array();
  3. for ( $i = 0; $i <=5; $i++ ) {
  4.     $bqtyd_array[$i] = JRequest::getBool('bqtyd'.$i, 'false', 'post');
  5.     $bqtyw_array[$i] = JRequest::getBool('bqtyw'.$i, 'false', 'post'); 
  6.     $fqtyd_array[$i] = JRequest::getBool('fqtyd'.$i, 'false', 'post');
  7.     $fqtyw_array[$i] = JRequest::getBool('fqtyw'.$i, 'false', 'post');
  8. }
  9. for ( $n = 0; $n <=5; $n++ ) { 
  10.     $tentm_array[$n] = JRequest::getBool('tentm'.$n, 'false', 'post');
  11. }
  12. if ($debug) {echo '<div>$tentm_array: '.print_r($tentm_array, true).'</div>';}
  13. $count['bsd'] = array_sum($bqtyd_array);
  14. $count['bsw'] = array_sum($bqtyw_array);
  15. $count['fcd'] = array_sum($fqtyd_array);
  16. $count['fcw'] = array_sum($fqtyw_array);
  17. $count['jrtm'] = array_sum($tentm_array);
Thank you
Apr 6 '10 #1
2 1338
code green
1,726 Expert 1GB
you need to read the value of the text box, whereas you just seen to be evaluating whether it is used.
A check box is not always set but a text box is.
Apr 7 '10 #2
apryl
2
Thanks code green. I ended up adding the values of the input boxes with javascript and then modified my code to request that specific value. Might not be the cleanest way to do it, but it works.
Apr 7 '10 #3

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

Similar topics

2
by: John Wilson | last post by:
Hello friends, I have this dynamic array(shown below) that I need to match to values (1 - 10) that I am returning from the database via DSN connection object. The values I need to match are on...
1
by: Sue Adams | last post by:
I have a form on an asp page and am trying to write the code to place the values of all checkboxes that have been selected, into an array. The checkbox values will be used in a dynamic sql statement...
9
by: NiQ | last post by:
Hello every one, this is about an array of string and may be have done several time before but i need it and wasnt able to find it so here is the problem i have an array of strings with contains...
14
by: Randell D. | last post by:
Folks, Here's my problem: I am createing an array in a file using the reslut of some PHP and MySQL processing. An example of my array would be examlpe="example one"; examlpe="example...
10
by: Geoff Cox | last post by:
Hello, I have a series of pages each of which creates an array of values. How do I keep all the array values until the last page? Cheers Geoff
1
by: Joep | last post by:
Hi, In VB.net I have an array which contains different values. For example: array(0) = 2 array(1) = 2 array(2) = 2 array(3) = 3 array(4) = 3 array(5) = 6 array(6) = 6
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
4
by: noddy | last post by:
I have a mysql table called Users The userID field values start at 100 and increment up from there I am trying to transfer values from this table into a javascript array Here is what the code...
2
by: blitzztriger | last post by:
Hello!! how do i insert values into mysql , after parsing a submiting textbox?? I made the arrays, so this should be a basic insertion of them in the db, but something is missing, or in the wrong...
5
by: Pukeko | last post by:
Hi, this is an array that is used for a dropdown menu. var imageArray = new Array( "ecwp://" + document.location.host + "/massey/images/massey/ massey_07_fullres.ecw", "ecwp://" +...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.