Order Form

Order form submission

Page 1 of 1

2 Replies - 5137 Views - Last Post: 09 October 2009 - 09:35 PM

#1 JDUenas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 14-May 09

Order Form

Post icon  Posted 08 October 2009 - 11:37 AM

So I am trying writing 2 html pages. One is titles 3a, and on this page you have an order form, and a javascript order button. You fill out the information on the form, and then select the order button. When you press the order button I want a pop-up window that states, You ordered n(the number entered on form)# of pizzas. You will receive a phone call at(phone number entered in form)




<body>

<p> PIZZA ORDER FORM </p>
	
		
<form name="input" action="popup" method="get">	 <!-- builds form -->

  Name:<input type="text" name="Name" value=" " size="20"><br>
  Phone:<input type="text" name="Phone" value=" " size="13"><br>
  Address:<input type="text" name="Address" value=" " size="100"><br/>
  Amount:<input type="text" name="Amount" value=" " size="8"><br/>
 
 </form>
		



<script type="text/javascript" language="Javascript" >


function show_confirm()
{
var r=confirm('You ordered pizzas.');// displays the message in a pop-up 																																			window

	if (r==true)				// on pop-up window is you select ok you 
		  {
 			window.open('3b.html', 'popup', 'width=300,height=400');;	// are linked to secondary local page  
		  }
	else						// if you select cancel 
		  {
			  window.open('3a.html', 'popup','width=300,height=400' );	 // this message is displayed
		  }
  
}

 
 </script>
 
 <input type="button" onclick="show_confirm()" value="Order" />	
 
 </body>
 </html>



This post has been edited by JDUenas: 08 October 2009 - 03:12 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Order Form

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Order Form

Posted 09 October 2009 - 07:08 AM

Here's a new show_confirm function for you:
<script type="text/javascript" language="Javascript" >
function show_confirm()
{
	var phone = document.forms['input']['Phone'].value;
	var number = document.forms['input']['Amount'].value;

	var message;
	if(Number(number) > 1) {
		message = "You ordered " + number + " pizzas. ";
	} else {
		message = "You ordered one pizza. ";
	}
	message += "You will recieve a call at " + phone + ".";
	
	var r=confirm(message);// displays the message in a pop-up																																			 window

	if (r==true)				// on pop-up window is you select ok you
	{
		window.open('3b.html', 'popup', 'width=300,height=400');;	// are linked to secondary local page  
	}
	else						// if you select cancel
	{
		window.open('3a.html', 'popup','width=300,height=400' );	 // this message is displayed
	}
}
</script>



What happens here is that first the phone and number values are extracted from the form. Next a message is constructed using these values and shown to the user. I've added a check for if only one pizza is ordered so the message is grammatically correct :P
Was This Post Helpful? 1
  • +
  • -

#3 JDUenas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 14-May 09

Re: Order Form

Posted 09 October 2009 - 09:35 PM

That is great!!!!! It worked perfectly!!! Thank you so much, I spent the last 18hrs staring at my computer screen trying to figure it out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1