Solved

php drop down menu

Posted on 2004-08-26
10
388 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
  • 5
  • 4
10 Comments
 
LVL 2

Expert Comment

by:gimmeadrink
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:bobsmi7
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:bobsmi7
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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
Comment Utility
>> 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Effective way to iterate over a python list 8 90
fizzArray  challenge 1 47
copyEvens challenge 6 63
mapBully challenge 6 88
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now