Link to home
Start Free TrialLog in
Avatar of bobsmi7
bobsmi7

asked on

php drop down menu

I would like to be able to have a drop down menu inside a text entry box.  The following is a section of code, listing two categories for input (PRIORITY and DEPARTMENT and .  Both have a blank text input box:

<tr>
<td colspan="2" class="ThRows">Add Page</td>
</tr>
<?php
if ($err_string != "") {
    print "<tr>";
    print "<td class=\"ThRows\"><Strong>Error:</Strong></td>";
    print "<td class=" . $css_class . " align=Default>" . $err_string . "</td>";
    print "</tr>";
}
?>
<tr>
<td class="ThRows">PRIORITY</td>

<?php
if ((!isset($_GET["add_fd0"])) && (!isset($_POST["add_fd0"]))) {
    $itemvalue = "";
} else {
    $itemvalue = qsrequest("add_fd0");
}

    $cellvalue = "<input type=\"text\" name=\"add_fd0\" option value=\"" . qsreplace_html_quote(stripslashes($itemvalue)) . "\">";
    if ($cellvalue == "") {
        $cellvalue = "&nbsp;";
    }
    print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
<td class="ThRows">DEPARTMENT</td>
<?php
if ((!isset($_GET["add_fd1"])) && (!isset($_POST["add_fd1"]))) {
    $itemvalue = "";
} else {
    $itemvalue = qsrequest("add_fd1");
}

    $cellvalue = "<input type=\"text\" name=\"add_fd1\" value=\"" . qsreplace_html_quote(stripslashes($itemvalue)) . "\">";
    if ($cellvalue == "") {
        $cellvalue = "&nbsp;";
    }
    print "<td class=" . $css_class . " align=Default >" . $cellvalue . "</td>";
?>
</tr>
<tr>
Avatar of gimmeadrink
gimmeadrink

Hi

Im not sure if I understand what you mean or not.

What i think you are after is basically a dropdown that you can edit dynamically to add new values (is that right?)

If so, this is the best one i have found:

http://webdeveloper.earthweb.com/repository/javascripts/2003/07/227971/pp_editable_dropdown.html

it looks a lot nicer than the others but it doesnt work (completly) for all browser (works perfect in IE), of course, u could fix it if u really wanted to, would most likely be a matter of not using std DOM.

Alternatively, the one i use is blueshoes

Its available here

http://developer.blueshoes.org/phpdocu/blueshoes_javascript/javascript_components/dropdown/Bs_Dropdown.html


Its pretty easy to use once u get the hang of it:

  classDropdown = new Bs_Dropdown();
  classDropdown.objectName = 'classDropdown';
  classDropdown.setValue('DEFAULTVALUE');
  classDropdown.classInput  = 'dropdownInput';
  classDropdown.classSelect = 'dropdownSelect';
  classDropdown.drawInto('classDropdownDiv');
  classDropdown.attachEvent('onChange', myAlert);

Just ensure u have

<div id="classDropdownDiv"></div>

or simular

There is more help in the URL above.

Is this what you were after? Let me know if u need help


Avatar of bobsmi7

ASKER

Actually, what I am looking for is a modification of the php code.  The above code is part of a script that generates an edit box with different fields listed and a text entry box after each one.  For instance, if I put a value in   $cellvalue = "<input type=\"text\" name=\"add_fd0\" option value=\""
it will show up in the text box next to that particular filed (PRIORITY, DEPARTMENT, etc.).

I would like to be able to turn that into a dropdown, instead.  Not sure how to fit that into the php code.

Thanks.
1. I dont think i understand your problem still now. As far as i understand, you are populating text boxes based on the INPUT. Then, ???  If you can explain me more appropriately, i will try to help you.

2. You can ask this Question directly to PHP Topic Area where you can get more and quick responses than here.
https://www.experts-exchange.com/Web/Web_Languages/PHP/
Avatar of bobsmi7

ASKER

I have made some progress, but not much.  I replaced:

 $cellvalue = "<input type=\"text\" name=\"add_fd0\" value=\"" . qsreplace_html_quote(stripslashes($itemvalue)) . "\">";

with:

$cellvalue = "<select name=\"add_fd0\">
<option value=\"importance\">stuff1</option>
<option value=\"importance\">stuff2</option>
</select>>";

I know they syntax isn't right, but  at least I get a dropdown menu.  It doesn't input, though.




I am sorry that I didnt understand what you want to do exactly.

Do you simply want to change the textbox into SELECTION box ? If so, where do you populate and use the different OPTIONS of the SELECTION box?

So far, what did you got and what do you want to get?
Avatar of bobsmi7

ASKER

This is an add_record dialogue box with add_fd0 being, say PRIORITY, add_fd1, DEPARTMENT, add_fd2, NAME, and so forth.  The records are stored in a mySQL database.  

At the present time, I can input into the individual fields with the:

 $cellvalue = "<input type=\"text\" name=\"add_fd0\" value=\"" . qsreplace_html_quote(stripslashes($itemvalue)) . "\">";

line, for each respective record (add_fd1, add_fd2, etc.).  What I would like to do is have a dropdown menu for a couple of them.  

I can send you the entire php script if that would help.
Avatar of bobsmi7

ASKER

Additional information:

When I run the script with the select statement, the word "importance" is added to the table instead of the value in the dropdown men (A, B, etc.).  Obviously, there must be something wrong with my select statement.

$cellvalue = "<select name='add_fd0'>
    <option value='importance'>A</option>
    <option value='importance2'>B</option>
    </select>";
 
ASKER CERTIFIED SOLUTION
Avatar of ldbkutty
ldbkutty
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> I can send you the entire php script if that would help.
Please post it here or send to my mail (if it is not too big)
Avatar of bobsmi7

ASKER

Thanks.  I'm kind of new at php and I do appreciate your help.  I did want to split a few of the points with the first person who answered but I must not have clicked the check box.