Page 1 of 1

Select box value is stoping at space

Posted: Wed Apr 28, 2010 10:42 am
by dimxasnewfrozen
I have no idea why this is happening but when I select a select box value from the box , the value that gets stored in the post variable stops at the space.

This select box:

Code: Select all

$d = "SELECT * FROM DEPARTMENTS";
$p = ociparse($cisConnection, $d);
ociexecute($p);
$d_nr = ocifetchstatement($p, $d_results);
	echo "<select id=\"forward_to\" name=\"forward_to\">";
		for ($d2=0; $d2 < $d_nr; $d2++ ){
			$department = $d_results['DEPARTMENT'][$d2];
			echo "<option style='padding:1px;' value=".$department.">" . $department ."</option>";
		}
      echo "</select>";
The select box is getting generated properly but when I submit the page for a selected value of "Human Resources"...
The $_POST['forward_to'] variable would be "Human ".

Re: Select box value is stoping at space

Posted: Wed Apr 28, 2010 10:51 am
by dimxasnewfrozen
Gah I got it...

Code: Select all

echo "<option style='padding:1px;' value= \"$department\">" . $department ."</option>";
instead of:

Code: Select all

echo "<option style='padding:1px;' value= ".$department.">" . $department ."</option>";

Re: Select box value is stoping at space

Posted: Wed Apr 28, 2010 11:27 am
by phu
You might want to consider separating your HTML from your PHP more clearly. A project larger than a single page can get very difficult to read and debug very quickly with the presentation and logic mixed up like this.

Re: Select box value is stoping at space

Posted: Wed Apr 28, 2010 3:59 pm
by Jonah Bron
Please edit your original post, and put [SOLVED] into the subject.