RSS Forums RSS

HELP - php code to post all list box values

Reply
Posts: 2
Reputation: Metse is an unknown quantity at this point 
Solved Threads: 0
Metse Metse is offline Offline
Newbie Poster

HELP - php code to post all list box values

  #1  
Jan 12th, 2009
'am a beginner & am busy designing a site that has simple order-form which captures details of a cust and submit them throuth as an email using php, which works fine.

my problem is i added 2 list boxes, one(as a drop-down) pre-populated with items-to-order which allows the user to add items in-need to the second list box...

how do i sumbit all values of the 2nd list box along as an email. My code currently is:
.
.
$listbox2 = $_POST('listbox2')
.
.
$message .= "items on order are: ";
$message .= $listbox2;
.
.

which doesn't work.

Please Help !!!!
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,006
Reputation: kkeith29 will become famous soon enough kkeith29 will become famous soon enough 
Solved Threads: 121
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Veteran Poster

Re: HELP - php code to post all list box values

  #2  
Jan 12th, 2009
you need to use brackets:

$listbox2 = $_POST['listbox2'];

is the select box multiple or not. is it returning only one value.
Reply With Quote  
Posts: 2
Reputation: Metse is an unknown quantity at this point 
Solved Threads: 0
Metse Metse is offline Offline
Newbie Poster

Re: HELP - php code to post all list box values

  #3  
Jan 12th, 2009
Thanks for the correction kkeith29

just made a typing error there.. my current code is currently as:

$listbox2 = $_POST['listbox2']; & still do not run well..
Reply With Quote  
Posts: 362
Reputation: ardav is an unknown quantity at this point 
Solved Threads: 42
ardav's Avatar
ardav ardav is offline Offline
Posting Whiz

Re: HELP - php code to post all list box values

  #4  
Jan 12th, 2009
I assume your 2nd listbox holds multiple items and therefore your posted listbox should be an array of items,e.g. $_POST['listbox2'][0], $_POST['listbox'][1], etc. Use a for or while loop until count($_POST['listbox']) to retrieve the items. Don't know if this will work - how is your 2nd listbox populated and are you multiselecting? I thought a simple listbox (select widget) just gave you the selected value on posting.

If you are posting to the same page (not recommended), then you will overwrite your $variable. Perhaps you could use a $_SESSION variable as a quick fix to hold this data?
Last edited by ardav : Jan 12th, 2009 at 6:24 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 1186 | Replies: 3 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:41 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC