multiple list
Hey Ray
ON the attached pages form, on line 565 I have a multiple list which allows you to select more than one entry from the list fine, but it doesnt submit more than the first one selected...
Many thanks
Jamie
Hey Ray
ON the attached pages form, on line 565 I have a multiple list which allows you to select more than one entry from the list fine, but it doesnt submit more than the first one selected...
Many thanks
Jamie
In php you have to name multiselect list elements with brackets at the end like: name="Accommodation[]"
That will make it so the selected values are submitted as an array. Then if you want to store them comma-separated you can use the implode function like:
<?php echo(isset($_POST['Accommodation'])?implode(",",$_POST['Accommodation']):""); ?>
so would that be to modify the <option> something like this
<?php if (!(strcmp("Albert Suite", ((isset($_POST["Accommodation"]))?$_POST["Accommodation"]:"")))) {echo "selected=\"selected\"";} ?>
to this
<?php if (!(strcmp("Albert Suite", (isset($_POST["Accommodation"]))?implode(",",$_POST['Accommodation'])))) {echo "selected=\"selected\"";} ?>
If so, I have doen something wrong as it 'breaks' the page
Jamie
First you would have to make sure the field was named with brackets or that would cause an error: name="Accomodation[]"
Then you would have to rewrite that code entirely like:
<?php if (isset($_POST["Accommodation"]) && in_array("Albert Suite",$_POST["Accommodation"])) {echo "selected=\"selected\"";} ?>
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.