0 Replies - 3020 Views - Last Post: 14 November 2012 - 04:24 PM

#1 ChiCityCode   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-November 12

Problem With Reservation Form Function

Posted 14 November 2012 - 04:24 PM

Hello everyone I'm new to this forum and new to coding so please excuse my lack of experience on this topic. I'm having trouble getting my function to properly obtain all the variables and output them into a message. I think the problem may be that my radio buttons and check boxes are not properly linked to my function. I'm really just not sure what I should be looking for at this point so any help would be greatly appreciated! Thanks!!!

<!DOCTYPE html>
<html lang="en">
	<title>Reservation Page</title>
	<meta charset="utf-8" />
	<script type="text/javascript">
	function doStuff()
		var last;
		var first;
		var city;
		var hotel;
		var travelers;
		var days;
		var wifi;
		var recline;
		var meal;
		last = document.reservation.txtLastName.value;
		first = document.reservation.txtFirstName.value;
		city = document.reservation.radio1.value;
		hotel = document.reservation.radio2.value;
		travelers = document.reservation.selTravelers.value;
		days = document.reservation.selDays.value;
		wifi = document.reservation.optional.value;
		recline = document.reservation.optional2.value;
		meal = document.reservation.optional3.value;
		city = parseInt(city);
		hotel = parseInt(hotel);
		travelers = parseInt(travelers);
		days = parseInt(days);
		wifi = parseInt(wifi);
		recline = parseInt(recline);
		meal = parseInt(meal);
		todaysDate = Date();
		totalCost = travelers*(city + (days*hotel) + wifi + recline + meal)
		document.write("We recieved your reservation on " +  todaysDate + ". Your total cost is $" + totalCost + ".");

	<link rel="stylesheet" type="text/css" href="style.css">
	<div id="header">
		<img src="BusLogo.jpg" alt="BusLogo" width="120%" height="120%">
		<h5>Chicago's Most Reliable Bus Service</h5>
	<div id="nav">
		<ul type="square">
			<li> <a href="busline_reservation.html">Make a Reservation</a> </li>
			<li> <a href="busline_contact.html">Contact Us</a> </li>
			<li> <a href="busline_mailing.html">Join Our Mailing List</a></li>
			<li> <a href="busline_home.html">Home</a></li>
	<div id="reservation_form">
		<form name="reservation">
			<p><b>Last Name:</b>
				<input type="text" name="txtLastName" style="background-color:#E0E0E0" />
			<p><b>First Name:</b>
				<input type="text" name="txtFirstName" style="background-color:#E0E0E0" />
			<p><b>Arrival City:</b><br />
			<input type="radio" name="radio1" value="40" class="styled" />St. Louis
			<input type="radio" name="radio1" value="20" class="styled" />Milwaukee
			<input type="radio" name="radio1" value="35" class="styled" />Detroit
			<p><b>Hotel Choice:</b><br />
			<input type="radio" name="radio2" value="50" class="styled" />$50/day
			<input type="radio" name="radio2" value="70" class="styled" />$70/day
			<input type="radio" name="radio2" value="120" class="styled" />$120/day
			<p><b>Number of Travelers: </b>
			<select name="selTravelers">
				<option value="1">1</option>
				<option value="2">2</option>
				<option value="3">3</option>
				<option value="4">4</option>
				<option value="5">5</option>
				<option value="6">6</option>
			<p><b>Number of Days: </b>
			<select name="selDays">
				<option value="2">2</option>
				<option value="3">3</option>
				<option value="4">4</option>
				<option value="5">5</option>
				<option value="6">6</option>
				<option value="7">7</option>
			<input type="checkbox" name="optional" value="10">Wifi
			<input type="checkbox" name="optional2" value="20">Fully-Reclining Seat <br />
			<p><b>Meal Choice:</b><br />
			<input type="radio" name="radio3" value="0" class="styled" />None
			<input type="radio" name="radio3" value="5" class="styled" />Snack
			<input type="radio" name="radio3" value="10" class="styled" />Full Meal
			<p><b>Special Requests:</b><br />
			<textarea rows="4" cols="35">
			<input type="button" value="Book My Trip!" style="background-color:#FFCC73;" onclick="doStuff()" />
	<div id="footer">
		<h6>875 N Michigan Ave<br />Chicago<br />312.751.3681</h6>

Attached File(s)

Is This A Good Question/Topic? 0
  • +

Page 1 of 1