Solved

php drop down menu

Posted on 2004-08-26
10
410 Views
Last Modified: 2012-06-22
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>
0
Comment
Question by:bobsmi7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 2

Expert Comment

by:gimmeadrink
ID: 11909096
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


0
 

Author Comment

by:bobsmi7
ID: 11914255
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.
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11916733
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.
http://www.experts-exchange.com/Web/Web_Languages/PHP/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bobsmi7
ID: 11917240
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.




0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11919021
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?
0
 

Author Comment

by:bobsmi7
ID: 11931569
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.
0
 

Author Comment

by:bobsmi7
ID: 11933890
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>";
 
0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 500 total points
ID: 11939871
>> 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.

Yes, if you want to get the values as A, B change your code to this:

$cellvalue = "<select name='add_fd0'>
    <option value='A'>A</option>
    <option value='B'>B</option>
    </select>";
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11939881
>> 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)
0
 

Author Comment

by:bobsmi7
ID: 11942520
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 73
Python Encoding Problem \u2013 4 138
countX 22 183
Problem to copy file 14 83
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question