Jump to content

Archived

This topic is now archived and is closed to further replies.

rajmohan

dyanmic menu generate using javascript or php?

Recommended Posts

Hai guys

i am creating a registration form where the client has to enter how many machine in one text field,

if the client enter 5 in text field . i has to create 5 menu below that text field how to write the coding

i think this can be done by javascript or php

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

×

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.