rajmohan Posted October 27, 2006 Share Posted October 27, 2006 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 codingi think this can be done by javascript or php Quote Link to comment Share on other sites More sharing options...
shadow-x Posted October 27, 2006 Share Posted October 27, 2006 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 menu10menu9etc...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 submittedif($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 :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.