Jump to content


dyanmic menu generate using javascript or php?

  • Please log in to reply
1 reply to this topic

#1 rajmohan

  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 27 October 2006 - 09:06 AM

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

#2 shadow-x

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 27 October 2006 - 10:33 AM

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


//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! -->";


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 :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users