0

Hi!
Just wanted to know if there is any special syntax to get values in <option> with a space between words.
For example:
<form action="abc.php" method="post">
<select name="study_class">
<option value="Class 1">CLASS 1</option>
<option value="Class 2">CLASS 2</option>
</select>
</form>

Can php recognize "Class 1" or "Class 2" or will it recognize only "Class" or "Class".

Thanks!

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by David2012
1

No, it should recognise "Class 1", "Class 2"..

<?php

  $study = $_POST['study_class'];

  var_dump($study);
?>

Then depending on whichever value is entered, should assign this.

I haven't tested it though, might be wrong!

0

Well..phorce..it works. But now it outputs the crude values like:
string(31)"Class 1, Class 2"
I don't want var_dump($study); to give any output on its own except to pass on all data

<form action="abc.php" method="post">
    <select name="study_class[]" multiple>
        <option value="Class 1">CLASS 1</option>
        <option value="Class 2">CLASS 2</option>
        <option value="Class 3">CLASS 1</option>
        <option value="Class 4">CLASS 2</option>
    </select>
</form>

abc.php
<?php
#get data
$study_class=implode(', ', $_POST['study_class']);
var_dump($study_class);
?>
<html>
.
.
<P> Study Classes Chosen are: <?php echo $study_class; ?></P>
.
</html>

OUTPUT:
string(31)"Class 1, Class 2"

Study Classes Chosen are: Class 1, Class 2

So, I do not want the 'string....' line to come up.
Moreover, in the php i would also be passing the multiple choices via mail.

Edited by David2012

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.