<html> <head> <title>Grocery List</title> <script type="text/javascript" language="JavaScript"> function addItem() { var myForm = document.forms.groceryList; var listAdd = []; for (i = 0; i < myForm.category.length; i++) { if (myForm.category[i].checked) { break; } } type = myForm.category[i].value; var myItem = document.getElementById("itemName").value; listAdd.push(type + " : " + myItem + "\n"); var area = document.getElementById('list'); area.value = listAdd + area.value; } function printSortedList() { newList = document.getElementById('list') newSort = newList.value; newItems = newSort.sort(); var tArea = document.getElementById('list'); tArea.value = newItems } </script> <style type="text/css"> body,td,th { color: #00F; } body { background-color: #E4E4E4; background-image: url(grocery_bag.jpg); } </style> </head> <body> <form action="#" name="groceryList"> Category: <input type="radio" name="category" value="Produce" />Produce <input type="radio" name="category" value="Meat and Cheese" />Meat and Cheese <input type="radio" name="category" value="Grocery" />Grocery <input type="radio" name="category" value="Beverage" />Beverage <br /> Item: <input name="item" type="text" id="itemName" size="30" /> <br /> <input type="button" name="add" value="Add to List" önclick="addItem()"/> <br /> <textarea name="list" rows="30" id="list" style="width:500" size="10"></textarea> </select> <br /> <input type="button" id="button" name="sort" value="Print Sorted List" önclick="printSortedList()"/> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)