Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

select multiple options in form

New Here ,
Jun 20, 2009 Jun 20, 2009

Hi

i have one little problem the grade or interest and specialties should be able to select multiple options and i have set this up but when i test it the information coming back on email shows only only on selection for these fields. Anyone know why. http://www.locumexpress.ie/online%20reg.php

Thanks

Natasha

TOPICS
Server side applications
611
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 20, 2009 Jun 20, 2009

When form fields allow multiple choices, the form must submit them as an array. To do this, add an empty pair of square brackets after the name attribute.

The name attribute of form elements should not contain any spaces, so this is invalid:

<select name="Grade of Interest" 

You should replace it with something like this:

<select name="Grade_of_interest[]" 

This submits the values as an array, so you need to use implode() to convert them back to a string:

if (isset($_POST['Grade_of_interest'])) {

  $

...
Translate
LEGEND ,
Jun 20, 2009 Jun 20, 2009

Please post PHP-related questions in the correct forum: Dreamweaver Application Development, where your thread has been moved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 20, 2009 Jun 20, 2009

When form fields allow multiple choices, the form must submit them as an array. To do this, add an empty pair of square brackets after the name attribute.

The name attribute of form elements should not contain any spaces, so this is invalid:

<select name="Grade of Interest" 

You should replace it with something like this:

<select name="Grade_of_interest[]" 

This submits the values as an array, so you need to use implode() to convert them back to a string:

if (isset($_POST['Grade_of_interest'])) {

  $_POST['Grade_of_interest'] = implode(', ', $_POST['Grade_of_interest'])

}

I also notice that you're using spaces in your file names. You should never put spaces in file or folder names on a website. The reason it's working now is because your site is hosted on a Windows server. If the site is ever moved to a Linux server (and most sites are hosted on Linux), it will break. Also, the %20 that represents the space in the middle of the URL looks ugly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2009 Jun 23, 2009
LATEST

Thanks for that

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines