Jump to content


Photo

List/Menu Field


  • Please log in to reply
2 replies to this topic

#1 mckinney3

mckinney3
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 29 October 2005 - 04:35 PM

I have inserted a List/Menu field using DW into a form. I have specified LIST and enabled ALLOW MULTIPLE. The action is to a PHP script resident on a GoDaddy hosting site. The form submits fine and I get the email that I have asked for. I get all the fields but for fields that should be returning multiple inputs such as the List/Menu field, I only get back one of the possible selections.

If I use the MENU variation , I get back the correct choice.

I am trying to figure out if the problem is DW code working with PHP in general or with GoDaddy's scripts or me.

here is a snippet of code with logo being the choice that is intially selected.

<td><select name="select" size="3" multiple>
<option value="logo" selected>logo</option>
<option value="decription">description</option>
<option value="feedback">feedback</option>
<option value="guestbook">guestbook</option>
</select></td>

#2 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 07 December 2005 - 10:53 AM

<td><select name="select" size="3" multiple>
<option value="logo" selected="selected">logo</option>
<option value="decription">description</option>
<option value="feedback">feedback</option>
<option value="guestbook">guestbook</option>
</select></td>


How come you modified the automatically inserted code?

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 07 December 2005 - 01:53 PM

[!--quoteo(post=325277:date=Dec 7 2005, 05:53 AM:name=morpheus.100)--][div class=\'quotetop\']QUOTE(morpheus.100 @ Dec 7 2005, 05:53 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<td><select name="select" size="3" multiple>
<option value="logo" selected="selected">logo</option>
<option value="decription">description</option>
<option value="feedback">feedback</option>
<option value="guestbook">guestbook</option>
</select></td>
How come you modified the automatically inserted code?
[/quote]

it depends on what version of dreamweaver whether or not "selected" or "selected='selected'" is generated. same thing with checkboxes. if you're using an older version (i believe MX or earlier), it will simply put "checked" as your value, not "checked='checked'". this is due to validation requirements of XHTML.

i believe the issue is that to return more than one value through PHP, you need to declare your select box as an array:

<?php
if (isset($_POST['select'])) {
  foreach ($_POST['select'] as $value) {
    echo "$value<br />\n";
  }
}
?>

<form name='test' action='' method='post'>
<select name='select[]' multiple='multiple'>
<option value="logo" selected='selected'>logo</option>
<option value="decription">description</option>
<option value="feedback">feedback</option>
<option value="guestbook">guestbook</option>
</select>
<input type='submit' name='submit' value='Submit' />
</form>

notice the name of the select field is "select[]" to declare it as an array!

try this out and see if it makes sense.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users