Jump to content

List/Menu Field


Recommended Posts

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>

Link to comment
Share on other sites

  • 1 month later...

<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?

Link to comment
Share on other sites

[!--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) 325277[/snapback][/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?

 

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.