www.webdeveloper.com
Results 1 to 2 of 2

Thread: Returning values of a Drop Down Menu

  1. #1
    Join Date
    Jan 2011
    Posts
    1

    Returning values of a Drop Down Menu

    I'm making a recipe box page where I let the users input the name, ingredients, time it takes, directions of it and save the recipe into the dropdown menu where if they click on the menu another time, it'll show the text they inputted. The problem is that once I save the things into the drop down menu, how do I actually return it again to the new page.

    http://img838.imageshack.us/img838/1286/25542890.png
    <!DOCTYPE HTML >
    <html>
    <head>
    <title> Food Network & Man v. Food </title>
    <script type = "text/javascript">
    foods = new Array();

    function food(f, c, di, i, dir)
    {
    this.foodName = f;
    this.cookTime = c;
    this.difficulty = di;
    this.ingredients = i;
    this.directions = dir;
    }

    function addFoodToList(currfood)
    {
    foodlist = document.getElementById("lst_foods");
    opt = document.createElement("option");
    opt.text = currfood.foodName;
    try
    {
    foodlist.add(opt, null);
    }catch(e)
    {
    foodlist.add(opt);
    }
    }

    function saveFood()
    {
    fname = document.getElementById("txt_recipe").value;
    ctime = document.getElementById("txt_time").value;
    diffic = document.getElementById("txt_difficulty").value;
    ing = document.getElementById("txt_ingredients").value;

    if (fname == "" || ctime == "" || diffic == "" || ing == "")
    {
    alert("You must fill in all of the fields");
    return;
    }

    for (i in foods)
    if (foods[i].foodname.toUpperCase() == diffic.toUpperCase())
    {
    alert("That foodname already exists.");
    return;
    }

    currfood = new food(fname, ctime, diffic, ing)
    foods.push(currfood);

    addFoodToList(currfood);
    }

    </script>
    </head>
    <body style = "background-image:url('enterpg3.png'); background-repeat: no-repeat; background-color:firebrick;; color:white">
    <br />
    <div style = "text-align:center; font-size:40pt">
    Recipe Box
    <div style = "font-size:15pt; text-align:center; font-style:italic"> Save your own recipes! </div>
    </div>
    <br />
    <h1>Please Input Your Recipe</h1>
    <span>
    <span>Recipe for: <input type = "text" id = "txt_recipe" /></span>
    <span> Cook/Prep Time: <input type = "text" id = "txt_time" /></span>
    <span>Difficulty: <input type = "text" id = "txt_difficulty" /></span>
    <span>Ingredients (separate by comma): <input type = "txt" id = "txt_ingredients" /></span> <br />
    Directions <br /><textarea id = "directions" rows = "15" cols = "65"> </textarea>
    </span>
    <div><input type = "button" value = "Save Recipe" onclick = "saveFood();" /></div>
    <hr />
    <h2>Recipe(s)</h2><br />
    <select id = "lst_foods"> <option> </option></select>
    <form method = "POST" action = "customRecipe.php"
    <select id = "lst_foods"> <option> </option></select>
    <input type = "submit" name = "submit" value = "Go to Recipe">
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    Since there is no php in your code why is it posted in the php section of the forum?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles