Click here to Skip to main content
15,886,963 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Java Script Slider Pin
Member 1146339918-Mar-15 2:43
Member 1146339918-Mar-15 2:43 
GeneralRe: Java Script Slider Pin
Afzaal Ahmad Zeeshan18-Mar-15 3:47
professionalAfzaal Ahmad Zeeshan18-Mar-15 3:47 
Questiongetting JSON data in much smaller way. Pin
Asif Rehman14-Mar-15 21:01
Asif Rehman14-Mar-15 21:01 
AnswerRe: getting JSON data in much smaller way. Pin
NAEEM272716-Mar-15 21:53
NAEEM272716-Mar-15 21:53 
AnswerRe: getting JSON data in much smaller way. Pin
Kornfeld Eliyahu Peter18-Mar-15 1:39
professionalKornfeld Eliyahu Peter18-Mar-15 1:39 
QuestionRe: getting JSON data in much smaller way. Pin
Asif Rehman19-Mar-15 0:25
Asif Rehman19-Mar-15 0:25 
AnswerRe: getting JSON data in much smaller way. Pin
Kornfeld Eliyahu Peter19-Mar-15 0:35
professionalKornfeld Eliyahu Peter19-Mar-15 0:35 
QuestionConnect a radio button, select box, and checkbox within a function. Pin
Member 1150835012-Mar-15 17:53
Member 1150835012-Mar-15 17:53 
I'm trying to connect the hotel amount with the amount per day. For instance, if you select two days staying at the Economy hotel, it doubles the amount rather than doubling the amount for they the stay at the hotel alone. I've created a variable for days and added it to my if statements to retrieve the value. It was retrieving the amount for a single day correctly, but once I added that variable it began doubling everthing else.




When the user submits their form, a cost estimate for their trip should appear in an alert box with all the options:
Quote:
Arrival City: Use a radio button. Choices should be Omaha ($200), Nashville ($250), Detroit ($150)
Number of days as a select box with options from 2 through 6
Select box for ‘Extra Baggage ($30 each)’. Options should be ‘No Extra Bags’, ‘1 Extra Bag’, ‘2 Extra Bags’, ‘3 Extra Bags’
Have a checkbox for the following: Bringing a pet ($60)
A radio button to select the type of hotel: Economy Hotel ($140), Standard Hotel ($220), Upscale Hotel ($300)


This what I have so far.

JavaScript
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<script type="text/Javascript">
		function arrivalCity ()
		{
		var cost = 0;
		var days;
		var radHotel;

		days = document.reservation.selDay.value;


			if (document.reservation.radCity[0].checked)
				{
					cost = 200;
				}
			if (document.reservation.radCity[1].checked )
				{
					cost = 250;
				}
			if (document.reservation.radCity[2].checked)
				{
					cost = 150;
				}
			if (document.reservation.chkYes.checked)
				{
					cost = cost + 60;
				}
			if (document.reservation.radHotel[0].checked)
				{
					cost = cost + 140;
				}
			if (document.reservation.radHotel[1].checked)
				{
					cost = cost + 220;
				}
			if (document.reservation.radHotel[2].checked)
				{
					cost = cost + 300;
				}
			if ( days == "two")
				{
					cost = cost * 2  ;
				}

			alert (cost) ;
		}
</script>
</head>
<body>
<div id="header">
	<form name="reservation">
		<p>Where are you traveling to? <br/>
			Omaha <input type ="radio" name="radCity"> <br>
			Nashville <input type="radio" name="radCity"><br>
			Detroit <input type="radio" name="radCity"> </p>

		<p>How many days are you staying?<br>
			<select name="selDay">
				<option value="two"> 2 </option>
				<option value="three"> 3 </option>
				<option value"four"> 4 </option>
				<option value="five"> 5 </option>
				<option value="six"> 6 </option>
			</select></p>

		<p>Extra Baggage ($30 each): <br>
			<select name="selBag">
				<option value="noBag"> No Extra Bags</option>
				<option value="oneBag"> 1 Extra Bag</option>
				<option value="twoBag">2 Extra Bags</option>
				<option value="threeBag"> 3 Extra Bags</option>
			</select> </p>

		<p>Bringing a pet ($60):<br>
			Yes <input type="checkbox" name="chkYes"><br>
			No <input type="checkbox" name="chkNo"> <br> </p>

		<p>Select the name of the hotel:<br>
		Economy Hotel <input type="radio" name="radHotel" value="$140"><br>
		Standard Hotel <input type="radio" name="radHotel" value="$220"><br>
		Upscale Hotel <input type="radio" name="radHotel" value="$300"><br>
		</select></p>



	<p><input type="button" value="Book My Ticket" onclick="arrivalCity ()"> </p>


</body>
</html><pre lang="Javascript">


modified 13-Mar-15 17:19pm.

QuestionThe Timer displayed is 1 hr (HH:MM:SS) in decrement order. I have to display a pop out when 50 mints complete after that remaining 10 mints one pop up should display saying 10 mints with 0 sec. After that for every 2 mintues the pop up appear showin Pin
Member 115026795-Mar-15 18:39
Member 115026795-Mar-15 18:39 
QuestionRe: The Timer displayed is 1 hr (HH:MM:SS) in decrement order. I have to display a pop out when 50 mints complete after that remaining 10 mints one pop up should display saying 10 mints with 0 sec. After that for every 2 mintues the pop up appear sh Pin
ZurdoDev11-Mar-15 9:47
professionalZurdoDev11-Mar-15 9:47 
QuestionHow I make a javascript wedget to place another website wedget Pin
Member 115008415-Mar-15 1:19
Member 115008415-Mar-15 1:19 
QuestionUnit testing for JavaScript/JQuery Code Pin
SaranshSrivastava28-Feb-15 20:53
SaranshSrivastava28-Feb-15 20:53 
Questionimage preview and save to a folder Pin
Member 1116631824-Feb-15 6:35
professionalMember 1116631824-Feb-15 6:35 
AnswerRe: image preview and save to a folder Pin
ZurdoDev24-Feb-15 11:01
professionalZurdoDev24-Feb-15 11:01 
AnswerRe: image preview and save to a folder Pin
Afzaal Ahmad Zeeshan28-Feb-15 22:06
professionalAfzaal Ahmad Zeeshan28-Feb-15 22:06 
GeneralRe: image preview and save to a folder Pin
Afzaal Ahmad Zeeshan16-Jun-15 5:43
professionalAfzaal Ahmad Zeeshan16-Jun-15 5:43 
GeneralRe: image preview and save to a folder Pin
Simewu16-Jun-15 12:08
professionalSimewu16-Jun-15 12:08 
AnswerRe: image preview and save to a folder Pin
Simewu16-Jun-15 12:09
professionalSimewu16-Jun-15 12:09 
Questionauto submit form Pin
joe-hanh24-Feb-15 6:22
joe-hanh24-Feb-15 6:22 
AnswerRe: auto submit form Pin
Afzaal Ahmad Zeeshan24-Feb-15 6:47
professionalAfzaal Ahmad Zeeshan24-Feb-15 6:47 
GeneralRe: auto submit form Pin
joe-hanh25-Feb-15 2:31
joe-hanh25-Feb-15 2:31 
QuestionGet selected Li from UL Pin
indian14323-Feb-15 15:02
indian14323-Feb-15 15:02 
AnswerRe: Get selected Li from UL Pin
Matt U.24-Mar-15 9:59
Matt U.24-Mar-15 9:59 
AnswerRe: Get selected Li from UL Pin
Simewu15-Jun-15 15:23
professionalSimewu15-Jun-15 15:23 
QuestionHiding a button which doesn't have an ID or Name Pin
indian14322-Feb-15 8:52
indian14322-Feb-15 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.