Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php drop down menu

Posted on 2004-08-26
10
Medium Priority
?
430 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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

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!

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

916 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