Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 5th, 2004, 10:14 AM
OrangeHeart OrangeHeart is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 OrangeHeart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to OrangeHeart
I'm so lost

Ok guys I’m totally lost! I have this programming class and I was doing fine. But the professor is an *** and goes to fast and doesn’t give the classroom a chance to understand what the hell is going on. With that said she assigned us to make an order form for the airlines just to practice. The goal is to get the input information from the user than calculate the order and then request a credit card number using window.prompt.

Here’s the thing.. She wants to make sure the forms shows that the user must enter information before proceeding else where in the form.

I’m new and slow to understanding JavaScript so please bare with me.

Bellow is what I have so far for the form part. But I’m having major issues on trying to fix the radio buttons so that one is selected only. As well as making sure the user selects an air company.



This is the code:
<script type="text/javascript">
function airline()
{
var txtnumber,total, subtotal, input;
input = document.airlineform.txtnumber.value;
if(input.length ==0)
window.alert("You must enter number of passengers","");




}

</script>

</head>

<body>

<form method="POST" action="--WEBBOT-SELF--" name="airlineform">
<!--webbot bot="SaveResults" U-File="Cocuments and SettingsOwnerMy DocumentsOrangeHeart_privateform_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<table border="1" width="100%">
<tr>
<td width="99%" align="right" colspan="5">
<p align="center"><font face="Batang" size="4"><b>&nbsp;Airline
Order Form</b></font></td>
</tr>
<tr>
<td width="17%" align="right"><b>Number of&nbsp; Passengers:</b></td>
<td width="82%" colspan="4">
<input type="text" name="txtnumber" size="20"></td>
</tr>
<tr>
<td width="17%" align="right"><b>Which Way:</b></td>
<td width="26%" align="center">
<input type="radio" value="V3" name="oneway">One Way&nbsp;&nbsp;
</td>
<td width="55%" align="center" colspan="3">
<input type="radio" value="V4" checked name="rt">Round Trip</td>
</tr>
<tr>
<td width="17%" align="right"><b>Airline:</b></td>
<td width="82%" colspan="4"><select size="1" name="dropmenu">
<option selected>American Airlines</option>
<option>Continental</option>
<option>Delta</option>
<option>Airways</option>
<option>Lan Ecuador</option>
</select></td>
</tr>
<tr>
<td width="17%" align="right"><b>Lunch Menu:</b></td>
<td width="26%">&nbsp;<input type="checkbox" name="chke" value="ON">
Chicken ($5.00)</td>
<td width="18%"><input type="checkbox" name="rb" value="ON"> Roast
Beef ($7.00)</td>
<td width="16%"><input type="checkbox" name="soda" value="ON"> Soda
($1.50)</td>
<td width="20%">&nbsp;<input type="checkbox" name="CA" value="ON">
Candy ($5.00)</td>
</tr>
<tr>
<td width="17%" align="right"><b>Total:</b></td>
<td width="82%" colspan="4">
<input type="text" name="txttotal" size="20"></td>
</tr>
<tr>
<td colspan="5" align="right">
<p align="center">
<input type="submit" value="Calculate Order" name="calculate" onclick="airline()" />
<input type="button" value="Submit Order" name="suborder"><input type="reset" value="Clear Form" name="clear"></td>
</tr>
</table>
<p>&nbsp;</p>
</form>




Reply With Quote
  #2  
Old June 5th, 2004, 11:56 AM
Ashkhan Ashkhan is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 372 Ashkhan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 57 sec
Reputation Power: 2
RE: I'm so lost

It is quite easy. Just pay more attention to your study materials or find some web reference.

I made some enhancements to your script. Try to analyse them. Good luck in your class.

<html>
<head>
<script type="text/javascript">

function airline()
{
total = 0;
proceed = true;

if (document.airlineform.txtnumber.value == "" || isNaN(document.airlineform.txtnumber.value)) {
window.alert("You must enter number of passengers","");
proceed = false;
}

if (document.airlineform.soda.checked) {
total += 1.5 * document.airlineform.txtnumber.value;
}

document.airlineform.txttotal.value = total;

if (!proceed) {
window.alert('You cannot proceed!');
}
}

</script>

</head>

<body>

<form method="POST" action="--WEBBOT-SELF--" name="airlineform">
<table border="1" width="100%">
<tr>
<td width="99%" align="right" colspan="5">
<p align="center"><font face="Batang" size="4"><b>&nbsp;Airline
Order Form</b></font></td>
</tr>
<tr>
<td width="17%" align="right"><b>Number of&nbsp; Passengers:</b></td>
<td width="82%" colspan="4">
<input type="text" name="txtnumber" size="20"></td>
</tr>
<tr>
<td width="17%" align="right"><b>Which Way:</b></td>
<td width="26%" align="center">
<input type="radio" value="V3" name="way">One Way&nbsp;&nbsp;
</td>
<td width="55%" align="center" colspan="3">
<input type="radio" value="V4" checked name="way">Round Trip</td>
</tr>
<tr>
<td width="17%" align="right"><b>Airline:</b></td>
<td width="82%" colspan="4"><select size="1" name="dropmenu">
<option selected>American Airlines</option>
<option>Continental</option>
<option>Delta</option>
<option>Airways</option>
<option>Lan Ecuador</option>
</select></td>
</tr>
<tr>
<td width="17%" align="right"><b>Lunch Menu:</b></td>
<td width="26%">&nbsp;<input type="checkbox" name="chke" value="ON">
Chicken ($5.00)</td>
<td width="18%"><input type="checkbox" name="rb" value="ON"> Roast
Beef ($7.00)</td>
<td width="16%"><input type="checkbox" name="soda" value="ON"> Soda
($1.50)</td>
<td width="20%">&nbsp;<input type="checkbox" name="CA" value="ON">
Candy ($5.00)</td>
</tr>
<tr>
<td width="17%" align="right"><b>Total:</b></td>
<td width="82%" colspan="4">
<input type="text" name="txttotal" size="20"></td>
</tr>
<tr>
<td colspan="5" align="right">
<p align="center">
<input type="submit" value="Calculate Order" name="calculate" onclick="airline()" />
<input type="button" value="Submit Order" name="suborder"><input type="reset" value="Clear Form" name="clear"></td>
</tr>
</table>
<p>&nbsp;</p>
</form>
</body>
</html>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > I'm so lost


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway