dcsimg
www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: I need help!!!

  1. #16
    Join Date
    Oct 2006
    Posts
    939
    Ok, modified to validate the selections. Adds option to remove items

    HTML Code:
    <html>
    <head>
    <script type="text/javascript">
    
    var orders=new Array();
    
    var hot=['Awakening Mocha','Caffe Mocha','White Mocha','Cappuccino','Caramel Latte','Caffe Latte','Americano','Hot Chai Latte','Hot Chocolate','Espresso','Fresh Brewed Coffee']
    var froz=['Awakening Mocha','Caffe Mocha','Chocolate Creme','Vanilla Creme','Mango Smoothie','Strawberry Sensation Smoothie','Wild Berry Desire Smoothie','Peach Keen Smoothie','Green Apple Smoothie','Superfruit Antiox Smoothie','Frozen Lemonade','Frozen Hot Chocolate']
    
    
    var siz=['Small','Medium','Large']
    var flav=['Almond','Ammaretto','Bavarian Chocolate','Butterscotch','Caramel Pecan','Chocolate Milano','Cinnamon','Egg Nog','French Vanilla','Gingerbread','Irish Creme','Peppermint','Praline','Tiramisu','Toasted Marshmallow','Toasted Walnut','Sugar Free English Toffee','Sugar Free Hazelnut','Sugar Free Irish Creme','Sugar Free Vanilla']
    var mlk=['2% Milk','Skim Milk','Soy Milk']
    
    
    
    function setup(ans) {
    	if(ans=='Hot Bar'){hc='hot';ans=hot}
    	else if(ans=='Frozen Bar'){hc='cold';ans=froz}	
    
    
    
    var txt = '<table><tr>';
    txt += '<td><span>Please select a '+hc+' Drink:</span><br>';
    	txt += '<select name="drink"><option value="">- Please Select -</option>';
    	for(i=0;i<ans.length;i++){txt+='<option value="'+ans[i]+'">'+ans[i]+'</option>';}
    	txt +='</select></td>';
    txt += '<td><select  name="size" size="'+(siz.length+1)+'">   <OPTGROUP label="Size" style="color:red">';
    	for(i=0;i<siz.length;i++){txt+='<option value="'+siz[i]+'">'+siz[i]+'</option>';}
    
    txt +='</OPTGROUP></td></tr><tr><td><span>Please select a flavor shot</span><br>';
    	txt += '<select name="flavor"><option value="">- Please Select -</option>';
    	for(i=0;i<flav.length;i++){txt+='<option value="'+flav[i]+'">'+flav[i]+'</option>';}
    	txt += '</select></td>';
    
    txt +='<td><span>Please select a milk:</span><br>';
    	txt += '<select name="milk"><option value="">- Please Select -</option>';
    	for(i=0;i<mlk.length;i++){txt+='<option value="'+mlk[i]+'">'+mlk[i]+'</option>';}
    	txt += '</select></td>';
    
    txt +='<td><span>More:</span><br><input type="checkbox" name="More" value="" onclick="this.value==\'\'?this.value=\'add Whipped Cream\':this.value=\'\'">Add Whipped Cream </td></tr></table>'
    txt +='<div style="text-align:right"><input type=button onclick="validate()" value="Get it!"></div>'
      document.getElementById('item1').innerHTML=txt
    }
    
    function validate(){	var f=document.getElementsByTagName('select')
    	for(i=0;i<f.length;i++){if(!f[i].value){alert('Select a '+f[i].name); return}}
    addItem('new')
    }
    
    
    function addItem(n){ 	document.getElementById('items').innerHTML='';	var t='';
    	if(n){for(i=0;i<document.forms[0].elements.length-2;i++){t+=''+document.forms[0].elements[i].value+' '}
    	orders.push(t)}
      for(i=0;i<orders.length;i++){
    		var newDiv=document.createElement("div");
    	navigator.appName=='Microsoft Internet Explorer' ? newDiv.setAttribute("className", "order") : newDiv.setAttribute("class", "order" );
    		newDiv.setAttribute("innerHTML",''+orders[i]+'<input type=button onclick="remove('+i+')" value="remove	"><HR>');
    	document.getElementById("items").appendChild(newDiv);
    	}
    }
    
    function remove(x){  orders.splice(x,1);addItem()}
    
    var items=['Panini','Salad','Soup','Beverage','Hot Bar','Frozen Bar']
    function NewItem() {
    	var txt = '<hr color="#008080"><br>'
    	txt +='<select onchange="setup(this.value)" size="'+items.length+'" ><option value="">- Please select -</option>';
    	for(i=0;i<items.length;i++){txt+='<option value="'+items[i]+'">'+items[i]+'</option>';}
    	txt+='</select>'
    return txt + '<p> </p>'
    }
    </script>
    
    
    
    </head>
    <body >
    <table id="order"><tr><td>
    <span style="font-size: 60; font-family: papyrus; font-weight: 900; color: #008080;">&nbsp&nbsp &nbsp Place Order</span>
    </td></tr>
    <tr><td>Thank you for visiting The Awakening Cafe online. Below is an order form to order a delivery or pick-up.
    
    <p></p>
    
    <form action="mailto:muzickid92@suddenlink.net" enctype="text/plain" name="order1" method="post">
    <TABLE><TR><TD id="start">
    	<script type="text/javascript">
    	document.write(NewItem())
    	</script>
    </TD>
    <TD id="item1"></TD></TR></TABLE>
    <div id="items"></div><p> </p>
    
    <input type="submit" value="Submit" /> 
     <input type="reset" value="Reset" />
    </form>
    
    </td>
    </tr>
    </table>
    </body>
    </html>

  2. #17
    Join Date
    Mar 2008
    Posts
    32
    Whats the URL for this site, i am intreaged as to what you have all ready?

  3. #18
    Join Date
    Oct 2006
    Posts
    939
    Sorry, firefox wasn't handling dom like IE and I'm not messing with this anymore today.

    HTML Code:
    <html>
    <head>
    <script type="text/javascript">
    
    var orders=new Array();
    
    var hot=['Awakening Mocha','Caffe Mocha','White Mocha','Cappuccino','Caramel Latte','Caffe Latte','Americano','Hot Chai Latte','Hot Chocolate','Espresso','Fresh Brewed Coffee']
    var froz=['Awakening Mocha','Caffe Mocha','Chocolate Creme','Vanilla Creme','Mango Smoothie','Strawberry Sensation Smoothie','Wild Berry Desire Smoothie','Peach Keen Smoothie','Green Apple Smoothie','Superfruit Antiox Smoothie','Frozen Lemonade','Frozen Hot Chocolate']
    
    
    var siz=['Small','Medium','Large']
    var flav=['Almond','Ammaretto','Bavarian Chocolate','Butterscotch','Caramel Pecan','Chocolate Milano','Cinnamon','Egg Nog','French Vanilla','Gingerbread','Irish Creme','Peppermint','Praline','Tiramisu','Toasted Marshmallow','Toasted Walnut','Sugar Free English Toffee','Sugar Free Hazelnut','Sugar Free Irish Creme','Sugar Free Vanilla']
    var mlk=['2% Milk','Skim Milk','Soy Milk']
    
    
    
    function setup(ans) {
    	if(ans=='Hot Bar'){hc='hot';ans=hot}
    	else if(ans=='Frozen Bar'){hc='cold';ans=froz}	
    
    
    
    var txt = '<table><tr>';
    txt += '<td><span>Please select a '+hc+' Drink:</span><br>';
    	txt += '<select name="drink"><option value="">- Please Select -</option>';
    	for(i=0;i<ans.length;i++){txt+='<option value="'+ans[i]+'">'+ans[i]+'</option>';}
    	txt +='</select></td>';
    txt += '<td><select  name="size" size="'+(siz.length+1)+'">   <OPTGROUP label="Size" style="color:red">';
    	for(i=0;i<siz.length;i++){txt+='<option value="'+siz[i]+'">'+siz[i]+'</option>';}
    
    txt +='</OPTGROUP></td></tr><tr><td><span>Please select a flavor shot</span><br>';
    	txt += '<select name="flavor"><option value="">- Please Select -</option>';
    	for(i=0;i<flav.length;i++){txt+='<option value="'+flav[i]+'">'+flav[i]+'</option>';}
    	txt += '</select></td>';
    
    txt +='<td><span>Please select a milk:</span><br>';
    	txt += '<select name="milk"><option value="">- Please Select -</option>';
    	for(i=0;i<mlk.length;i++){txt+='<option value="'+mlk[i]+'">'+mlk[i]+'</option>';}
    	txt += '</select></td>';
    
    txt +='<td><span>More:</span><br><input type="checkbox" name="More" value="" onclick="this.value==\'\'?this.value=\'add Whipped Cream\':this.value=\'\'">Add Whipped Cream </td></tr></table>'
    txt +='<div style="text-align:right"><input type=button onclick="validate()" value="Get it!"></div>'
      document.getElementById('item1').innerHTML=txt
    }
    
    function validate(){	var f=document.getElementsByTagName('select')
    	for(i=0;i<f.length;i++){if(!f[i].value){alert('Select a '+f[i].name); return}}
    addItem('new')
    }
    
    
    function addItem(n){ 	document.getElementById('items').innerHTML='';	var t='';
    	if(n){ for(i=0;i<document.forms[0].elements.length-2;i++){t+=''+document.forms[0].elements[i].value+' '}
    	orders.push(t);}
    	var ord='';
      for(i=0;i<orders.length;i++){
    		ord+='<div >'+orders[i]+'<input type=button onclick="remove('+i+')" value="remove"></div>';}
    	document.getElementById("items").innerHTML=ord;
    	
    }
    
    function remove(x){  orders.splice(x,1);addItem()}
    
    var items=['Panini','Salad','Soup','Beverage','Hot Bar','Frozen Bar']
    function NewItem() {
    	var txt = '<hr color="#008080"><br>'
    	txt +='<select onchange="setup(this.value)" size="'+items.length+'" ><option value="">- Please select -</option>';
    	for(i=0;i<items.length;i++){txt+='<option value="'+items[i]+'">'+items[i]+'</option>';}
    	txt+='</select>'
    return txt + '<p> </p>'
    }
    </script>
    
    
    
    </head>
    <body >
    <table id="order"><tr><td>
    <span style="font-size: 60; font-family: papyrus; font-weight: 900; color: #008080;">&nbsp&nbsp &nbsp Place Order</span>
    </td></tr>
    <tr><td>Thank you for visiting The Awakening Cafe online. Below is an order form to order a delivery or pick-up.
    
    <p></p>
    
    <form action="mailto:muzickid92@suddenlink.net" enctype="text/plain" name="order1" method="post">
    <TABLE><TR><TD id="start">
    	<script type="text/javascript">
    	document.write(NewItem())
    	</script>
    </TD>
    <TD id="item1"></TD></TR></TABLE>
    <div id="items"></div><p> </p>
    
    <input type="submit" value="Submit" /> 
     <input type="reset" value="Reset" />
    </form>
    
    </td>
    </tr>
    </table>
    </body>
    </html>

  4. #19
    Join Date
    Nov 2009
    Posts
    8
    Quote Originally Posted by spinnykid View Post
    Whats the URL for this site, i am intreaged as to what you have all ready?
    The site isn't online yet. I'll post it once it is.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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