Jump to content

dyanmic menu generate using javascript or php?


rajmohan

Recommended Posts

Hi there, Ive made a simple script that will show a text field asking for the number of menus to create then once submitted it will generate that many menus and label them in reverse order, eg the user wants 10 menus they will be created as
menu10
menu9
etc...
menu1

[code]<?

//number will be a variable telling how many times to repeat the code.

$number = $_GET['number'];

//check to see if the form has been submitted

if($number == NULL){
//not subitted so show the form

echo "<HTML>
<!-- any HTML code the form itself will go here eg... --> <center>Number of menus to create<BR><form action=form.php method=get><input type=text name=number><input type=submit value=Create></form>";

} else {
//the form has already been submitted by the user so proccess the info.

//first we will set up the top of the HTML page

echo "<HTML><head><title>A title!</title><body> <BR> <!-- anything you want to show on the HTML page above the menu section has to go here! -->";
while ($number > 0) {
echo "
<!-- all html code here for the menus eg <option blah blah name=$number> (name=$number names the fields or other menu with the number it is, eg if the user wants 3 menus they will be called 1, 2 and 3 in REVERSE order.) Only ONE menu here,it will be repeated!-->
Menue $number <BR>";

//now take one away from the number variable

$number = $number - 1;
}
//now we end the HTML page here

echo "</body></HTML><!-- anything to go at the bottom of the HTML page below the menus goes in this line! -->";
};

?>[/code]

All formatting can be changed, ive called it form.php but that can be changed also to save it as you like but remember to change the action on the form also! Its only basic so use it as you like :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.