Dynamic Drop Down Menu


 
Thread Tools Search this Thread
Top Forums Web Development Dynamic Drop Down Menu
# 1  
Old 06-30-2010
Dynamic Drop Down Menu

I need to create a dynamic drop down menu which is populated by entries such as;

htdocs/client1/index.php
htdocs/client2/index.php
htdocs/client3/index.php
htdocs/client4/index.php
etc.

So htdocs/client*/index.php

Is this possible?

I know how to do this using normal arrays, but not sure if a dynamic drop down would be possible without using a DB.
JayC89
# 2  
Old 07-05-2010
Just use a bash/ksh script.
Code:
#!/bin/ksh
#clientlist
list=`ls -d client*`
i=1
for file in $list
do
if [ -d $list ]
then
echo \<option value="i"\>  $list\</option\>
i=`expr $i + 1`
fi
done

Code:
<select name="client" size="1">
<?php `clientlist` ?>
</select>

I didn't check the syntax of the echo statement for meta characters.
# 3  
Old 08-19-2010
Sorry for the delayed reply. I have added this into my index however made a slight change to the shell script so it didnt loop within itself;

Code:
#!/bin/sh
list=`ls -d /*`
i=1
for file in $list
do
if [ -d $file ]
then
echo \<option value="i"\>  $file\</option\>
i=`expr $i + 1`
fi
done

However which ever way I do it the drop down menu just comes back blank.

Any ideas?

Thanks Smilie

---------- Post updated at 04:27 PM ---------- Previous update was at 02:17 PM ----------

Managed to get it working using;

Code:
for list in `ls -d /usr/local/apache2/htdocs/services/* | sed 's/\// /g' | awk {'print $6'}`;
        do
                if [ -d $file ];
                then
                        echo '<option value="'/cgi-bin/$list.sh'">'$list'</option>'
                fi
        done

JayC89
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

Google Site Search in Search Drop Down Menu (Again)

Have just added (after missing for some time), the latest version of Google Site Search for our site in the Navbar Search Menu: https://www.unix.com/members/1-albums215-picture791.png Cheers and Enjoy. Here is the URL for that link in case you need it: https://goo.gl/P8p82c (4 Replies)
Discussion started by: Neo
4 Replies

2. UNIX for Dummies Questions & Answers

Dynamic menu selection? Help..

Hi guys, i would like to create a program that allow user to show the information of certain thing such as network card. I would like the menu to be dynamic, for example: my computer system have 2 network card inserted at the moment, therefore the menu will have 2 choice for the user. eth0... (12 Replies)
Discussion started by: malfolozy
12 Replies

3. Shell Programming and Scripting

How to select a particular field from a drop-down menu in a webpage using perl script?

Hi Team, I have a requirement to login into URL using username and password , then I have to select a "particular name" from drop-down menu and then Read the values user records etc.... using perl. Is it possible to do in perl script ? (OR) Can you please let me know which scripting... (1 Reply)
Discussion started by: latika
1 Replies

4. Shell Programming and Scripting

Drop down menu

How to create a drop down menu in either bash or ksh? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

5. Shell Programming and Scripting

Dynamic Drop down boxes

Hello All, I am trying to come up with this interface with the backend on perl. The interface needs drop down boxes with dynamic chain loading ( as in contents of the 1st drop down box will populate the second drop down and so on) Any idea how I can do this? Kindly help Regards, Garric (13 Replies)
Discussion started by: garric
13 Replies

6. Shell Programming and Scripting

Dynamic Menu Help

I'm working on a menu to read folders in as menu selections then CD to the selected folder and display the contained files as menu selections for execution. I'm using the following to read in the file list but I get lost after that. I only read in files that begin with CAPs. The problem is... (3 Replies)
Discussion started by: ScottKe
3 Replies

7. Shell Programming and Scripting

Drop down menu in bash for timezone select

Is there any way to implement a drop down menu selection in bash? This is on CDLinux which is a very minimal live CD and I am using it to install an image onto a hard drive. Part of that process is the timezone selection. There are just too many timezones to attempt to use the "select" command.... (1 Reply)
Discussion started by: simonb
1 Replies

8. Shell Programming and Scripting

dynamic Select menu

Hi all is menu driven by SELECT can be a dynamic ? My requirement is that i want SELECT to be created on run time not predefine . The select should be created as per the no of words in a file thanks in advance rawat (2 Replies)
Discussion started by: rawatds
2 Replies

9. Shell Programming and Scripting

Dynamic select with multiple word menu items

Hello all, I'm developing a deployment script at work and at one point it would need to display something like this: Which version of ADMIN would you like to deploy? 1) 1.0.0 (store1, 10 Jan 2004) 2) 1.0.1 (store1, 20 Jun 2004) 3) 1.0.2 (store1, 15 Jul 2004) Select a version : I know... (5 Replies)
Discussion started by: domivv
5 Replies
Login or Register to Ask a Question