1
phillipd
Strugglnig to read the selected string from a dropdown
  • 2004/7/16 6:57

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I have a dropdown "select" in a form that was filled in from a DB. I'm trying to read the selected value. I can't seem to figure this out. Can someone please assist me?

Loading the dropdown works fine:

$results = $xoopsDB->query("SELECT `types_title` FROM ". XOOPS_DB_PREFIX ."_dar_types");
$select_str = "";
while ($opt = $xoopsDB->fetchArray($results)) {
$sel = $opt['types_title'];
$select_str .= "\n";
}

echo "

";

// "select_str" are the "option values" for the select gadget
echo "
";

Notice I set the stage to 2 and when the submit button is pressed it reruns the same code which tries to extract the value of the dropdown but I can't seem to get the syntax correct...

if($stage == 2) {
$res = $_POST['selection']; <=== won't read the selection...
echo $_POST['selection'];
echo "
";
}
else {
echo "
";
}

Any help is greatly appreciated...

Thanks

Doug P

2
Mithrandir
Re: Strugglnig to read the selected string from a dropdown

if you just want a single value sent, you should not give the SELECT a name ending with [] as this indicates an array value to the output

3
phillipd
Re: Strugglnig to read the selected string from a dropdown
  • 2004/7/16 14:21

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I think I've tried that, to no avail. Do you have a sample snippit of reading an item from a dropdown that you know works? Thank you for your valuable time sir!

[Edit]

Figured it out... I didn't realize I needed the text in two places in the option value statement.

I was doing:

$select_str .= "\n";

Needed...

$select_str .= "\n";


Regards

Doug P

4
Mithrandir
Re: Strugglnig to read the selected string from a dropdown

Bleh... I should have caught that one.

"._XD_SELTITLE."



"._XD_TITLE."
"._XD_TITLE."
Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits