|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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="C <table border="1" width="100%"> <tr> <td width="99%" align="right" colspan="5"> <p align="center"><font face="Batang" size="4"><b> Airline Order Form</b></font></td> </tr> <tr> <td width="17%" align="right"><b>Number of 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 </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%"> <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%"> <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> </p> </form> |
|
#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> Airline Order Form</b></font></td> </tr> <tr> <td width="17%" align="right"><b>Number of 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 </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%"> <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%"> <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> </p> </form> </body> </html> |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > I'm so lost |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|