SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old June 6th, 2003, 11:52 AM
quietstorm quietstorm is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 quietstorm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy checkbox array problem

Hello to all of you,

Somebody please help. I am quite a newbie in php.


1. How do i write the values of my checkbox as array? The value "Home" is equivalent to $30.00. The same goes with "About Us" and "Services/Products"

Here's the piece of my html form:

<form name="form1" method="post" action="quote.php">

<input type="checkbox" name="chkProvide[]" value="Home>
Home<br> // Home has a corresponding value of $30.00

<input type="checkbox" name="chkProvide[]" value="About Us">
About Us<br> //About Us also has a corresponding value of
$ 30.00

<input type="checkbox" name="chkProvide[]"
value="Services/Products">
Services / Products<br> //Services/Products also has a
corresponding value of $ 30.00



2. How do i display the checked items in another form using Post method with their corresponding price and their total? I've tried using foreach() but can't get it to work.

Help is very much appreciated Thanks in advance!

Reply With Quote
  #2  
Old June 6th, 2003, 12:27 PM
bhoy bhoy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 3 bhoy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Since I know how disappointing it is when nobody answers you post, I'll try and start you off ....

... try indexing the array ...

<input type="checkbox" name="chkProvide[0]" value="Home>
Home<br> // Home has a corresponding value of $30.00

<input type="checkbox" name="chkProvide[1]" value="About Us">
About Us<br> //About Us also has a corresponding value of
$ 30.00

<input type="checkbox" name="chkProvide[2]"
value="Services/Products">
Services / Products<br> //Services/Products also has a
corresponding value of $ 30.00


Once the array in indexed, you should be able to loop through it.

Reply With Quote
  #3  
Old June 6th, 2003, 01:44 PM
quietstorm quietstorm is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 quietstorm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks. But how am i going to write the values for my Home, About Us, and Products/Services in my html form, which is $30.00?

Isn't it that we can loop through it by just using foreach()?

Reply With Quote
  #4  
Old June 6th, 2003, 02:18 PM
bhoy bhoy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 3 bhoy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
To be honest, I'm not exactly clear on what you're trying to do. However ...


If you want to pass the value (30), you can do it this way:

<input type="checkbox" name="chkProvide[Home]" value="30">
<input type="checkbox" name="chkProvide[About]" value="30">
<input type="checkbox" name="chkProvide[Services]" value="30">

If a box is checked, 30 will be passed as the value for the Index. If the box is not checked, no index or value will be passed.

If no index or value is passed, you could use an if statement to assign a value of zero, it that's what you want to do.

if($chkProvide[Home] != 30){
$chkProvide[Home] = 0;
}

if($chkProvide[About] != 30){
$chkProvide[About] = 0;
}

if($chkProvide[Services] != 30){
$chkProvide[Services] = 0;
}

Then, in the form ...

echo("<input type='hidden' name='Home' value='$chkProvide[Home]'>");

etc ...


I have to sign off now. I hope this is of some help. Good luck.

Reply With Quote
  #5  
Old June 7th, 2003, 05:21 AM
quietstorm quietstorm is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 quietstorm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks bhoy! I was able to make it work! I'll post my code as soon as i finished it. You're a great help. Thanks!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > checkbox array problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway