Solved

php drop down menu

Posted on 2004-08-26
10
401 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
viewing source code from eclipse 13 107
Specific format 21 198
split53 challenge 7 97
How To Loop - Python 19 87
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

777 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