Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: confirmation pop up, help!

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default confirmation pop up, help!

    I was wondering what I would have to do to have a transaction summary before moving onto the next page. I mean I would click "Buy Tickets" a pop up would show me what I was purchasing (for example. 2 tickets for Nottingham, 18th July at £45 each and the total cost (£90)) .

    Anyone have any ideas how to go about this?

    <html>
     
    <head>
    <a href="2.html" style="text-decoration: none"> Purchase different tickets 
    <br><<</a>
    <center>
    <br>
    <br>
    <br>
    <h1><FONT COLOR="06799F">Oasis</FONT></h1>
     
     
    </head>
     
     
    <body>
     
     
     
    <br /><br /><br /><br /><br />
     
     
    <form name="tickets">
     
    <select id="sel_1"><option value="">Select Ticket (s)</option></select>
    <select id="sel_2"><option value="">Select Number of Ticket (s)</option></select>
    <input type="button" value="Calculate Price" onclick="calcTic(this.form)" /> 
    <br /><br /><b>Total price(&pound;):</b> <input name="total"type="text" />
     
    <br /><br />(Includes £10 fee for 4+ tickets)
     
     
    </form>
     
     
    <br /><br /><br />
     
     
    <!--form to enter details-->
     
     
    <h2>Please Enter Your Details Below.</h2>
     
     
    <form name="form1">
    <b>Name:</b> <br /><input type="text" name="Name" value="" size="30" maxlength="50" /> <br><br>
     
    <b>Address:</b><br>
    <input type="text" name="Address1" value="Line 1" size="30" maxlength="50" />
    <br><input type="text" name="Address2" value="Line 2" size="30" maxlength="50" />
    <br><input type="text" name="Address3" value="Town/City" size="30" maxlength="50" />
    <br><input type="text" name="Address4" value="Postcode" size="30" maxlength="50" />
     
    <br><br><b>Telephone:</b> <br /><input type="text" name="Phone" value="" size="30" maxlength="11" /> <br><br>
     
    <b>Email:</b><br><input type="text" name="Email" value="" size="30" maxlength="50" /><br><br>
     
     
    <b>Card Number:</b><br><input type="text" name="Card" value="" size="30" maxlength="16" />
     
    </form>
     
     
    <br><br>
     
    <input type="submit" value="Buy Tickets" onclick="validate();" />
    <br /><br />
     
     
    </center>
     
     
    <script type = "text/javascript">
     
    var tickets=[
    [" "],
    ["Nottingham, 18th July",25],								//arrays to fill up the drop down
    ["Nottingham, 18th July",45],
    ["Nottingham, 18th July",60],
    ["Nottingham, 19th July",25],
    ["Nottingham, 19th July",45],
    ["Nottingham, 19th July",60],
    [" "],
    ["Glasgow, 21st July",45],
    ["Glasgow, 21st July",60],
    [" "],
    ["London, 23rd July",45],
    ["London, 23rd July",60],
    ["London, 24th July",45],
    ["London, 24th July",60]
    ],
    sel_1=document.getElementById("sel_1"),							//ticket drop down	
    sel_2=document.getElementById("sel_2");							//number of tickets drop down
     
    for(var i=1;i<tickets.length;i++){sel_1.options[i]=new Option(tickets[i][0]+' - '+tickets[i][1],tickets[i][1]);}
    for(var i=1;i<7;i++){sel_2.options[i]=new Option(i,i);}										//populating second drop down (1-6)
     
    function calcTic(frm)
    {
    if(frm.sel_1.value==""){alert("Please choose dates.");frm.sel_1.focus();return;}						//if unchosen ticket, alert before calculating price
    if(frm.sel_2.value==""){alert("Please choose number of tickets.");frm.sel_2.focus();return;} 					//if unchosen number of tickets, alert before calculating price
     
    else{
    var val_1=new Number(frm.sel_1.value),val_2=new Number(frm.sel_2.value),extra=val_2>3?10:0;					//totals up the price (ticket x quantity (+£10 if 4 or more))
    frm.total.value=val_1*val_2+extra;
    }
    }
     
    function validate()
    {
    var x=document.forms["form1"]["Name"].value;						//validate the name field
    if (x==null || x=="")
      {
      alert("Please fill in your Name.");							//show message if empty
      return false;
      }
     
    else if (document.form1.Name.value.length < 3 || null)					//if name is under 3 characters, show alert
    { 
    alert("Please enter your name correctly!");
    document.form1.Name.focus();
     return false;
    }
     
    var x=document.forms["form1"]["Address1"].value;					//validate the first line of address field
    if (x==null || x=="")
      {
      alert("Please fill in your first line of address.");					//show message if empty
      return false;
      }
     
     
    var x=document.forms["form1"]["Address2"].value;					//validate the second line of address field
    if (x==null || x=="")
      {
      alert("Please fill in your second line of address.");					//show message if empty
      return false;
      }
     
     
    var x=document.forms["form1"]["Address3"].value;					//validate the town/city field
    if (x==null || x=="")
      {
      alert("Please fill in your town/city.");						//show message if empty
      return false;
      }
     
    var x=document.forms["form1"]["Address4"].value;					//validate the postcode field
    if (x==null || x=="")
      {
      alert("Please fill in your postcode.");						//show message if empty
      return false;
      }
     
    var x=document.forms["form1"]["Phone"].value;						//validate the phone number field
    if (x==null || x=="")
      {
      alert("Please fill in your phone number.");						//show message if empty
      return false;
      }
    else if (document.form1.Phone.value.length < 11 || null)				//if phone number is under 11 numbers, show alert
    { 
    alert("Please enter your phone number correctly!");
    document.form1.Phone.focus();
     return false;
    }
     
     
    var x=document.forms["form1"]["Email"].value;						//validate the email
    var atpos=x.indexOf("@");		
    var dotpos=x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)					//check for the "@" and "."
      {
      alert("Not a valid e-mail address.");
      return false;
      }
     
     
    var x=document.forms["form1"]["Card"].value;						//validate the card field
    if (x==null || x=="")
      {
      alert("Please fill in your Card number.");						//show message if empty
      return false;
      }
     
    window.location= "thanks.html";
     
    }
     
     
     
    //session expiry
     
    setTimeout( "_SessionExpired()", 20 * 60 * 1000 );					//expires after 20 mins
     
    function _SessionExpired()
    {
    alert("Session has expired!");								//alerts user
    location.href = "1.html";								//redirects to login page
    }
     
     
    </script>
    </body>
     
    </html>

    any help appreciated!

    Thanks in advance


  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: confirmation pop up, help!

    also, I have tried a few ways but I can't seem to get a "£" sign in front of the prices on the drop down without changing the value of the field.
    Any suggestions on how to change?

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: confirmation pop up, help!

    Try a javascript or html forum. This one is for java.
    If you don't understand my answer, don't ignore it, ask a question.