Jump to content

Archived

This topic is now archived and is closed to further replies.

mckinney3

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>

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.