| Re: Strugglnig to read the selected string from a dropdown |
| by Mithrandir on 2004/7/16 16:16:58 Bleh... I should have caught that one. |
| Re: Strugglnig to read the selected string from a dropdown |
| by phillipd on 2004/7/16 14:21:56 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 .= "<OPTION VALUE=>$sel</OPTION>\n"; Needed... $select_str .= "<OPTION VALUE='$sel'>$sel</OPTION>\n"; Regards Doug P |
| Re: Strugglnig to read the selected string from a dropdown |
| by Mithrandir on 2004/7/16 12:28:06 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 |
| Strugglnig to read the selected string from a dropdown |
| by phillipd on 2004/7/16 6:57:57 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 .= "<OPTION VALUE=> $sel</OPTION>\n"; } echo "<form action='index.php' method='post'> <table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td class='bg2'> <table width='100%' border='0' cellpadding='4' cellspacing='1'>"; // "select_str" are the "option values" for the select gadget echo " <tr><td nowrap='nowrap' class='bg3'>"._XD_SELTITLE." </td><td class='bg1'><SELECT name='selection[]' size='1'> $select_str</SELECT> <input type='submit' name='editcontents' value='"._SUBMIT."' /> <input type='hidden' name='op' value='listcontents' /> <input type='hidden' name='stage' value='2' /> <input type='hidden' name='cat_id' value='".$cat_id."' /></td>"; 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 "<tr><td nowrap='nowrap' class='bg3'>"._XD_TITLE." </td> <td class='bg1'><input type='text' name='contents_title' value='$selection' size='52' maxlength='255' /></td></tr>"; } else { echo "<tr><td nowrap='nowrap' class='bg3'>"._XD_TITLE." </td> <td class='bg1'><input type='text' name='contents_title' value='$selection' size='52' maxlength='255' /></td></tr>"; } Any help is greatly appreciated... Thanks Doug P |