im having trouble with this, as it stands it works, but i need it to also check that no of passangers is less than 5 if not an alert msut be displayed. also to check that both firstname and surname are filled in. when i add in a function for on submit the whole lot stops working, anyone know how or why or how to fix this?
it for my college assessment
Code:<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.0 transitional//EN"> <html> <head> <title>Booking form</title> <script language="javascript" type="text/javascript"> expireDate= new Date expireDate.setMonth(expireDate.getMonth()+3) userName = "" thedate= "" if (document.cookie !="") { uName = document.cookie.split("=") [1] } function setCookie() { uName = document.book.firstname.value document.cookie = "userName=" + uName+ "; expires=" + expireDate.toGMTString() } bookload=function() { var check400=document.book.berth4; check600=document.book.berth6, inner=document.book.Cabin1, outer=document.book.Cabin2, total1=document.book.total1, total2=document.book.total2, total3=document.book.total3, total1.disabled='disabled', // remove this part if you want to enable total1 textbox total2.disabled='disabled', // remove this part if you want to enable total2 textbox total3.disabled='disabled', // remove this part if you want to enable total2 textbox total1.value='0', //This part is to initialize your inputs value to 0 total2.value='0', //This part is to initialize your inputs value to 0 total3.value='0', //This part is to initialize your inputs value to 0 check400.onclick=function() { if(this.checked) { total1.value='400'; total2.value='0'; //This is to ensure that all elements are reset total3.value='0'; //This is to ensure that all elements are reset inner.checked=false; //This is to ensure that all elements are reset outer.checked=false; //This is to ensure that all elements are reset check600.checked=false; // Remove this part if you want your check box to fire as normal one. //checknull.checked=false; } } check600.onclick=function() { if(this.checked) { total1.value='600'; total2.value='0'; //This is to ensure that all elements are reset total3.value='0'; //This is to ensure that all elements are reset inner.checked=false; //This is to ensure that all elements are reset outer.checked=false; //This is to ensure that all elements are reset check400.checked=false; // Remove this part if you want your check box to fire as normal one. //checknull.checked=false; } } inner.onclick=function() { if(this.checked) total2.value='0'; outer.checked=false; // Remove this part if you want your check box to fire as normal one. total3.value=Number(total1.value)+Number(total2.value); } outer.onclick=function() { if(this.checked) total2.value='100'; inner.checked=false; // Remove this part if you want your check box to fire as normal one. total3.value=Number(total1.value)+Number(total2.value); } }//end onload function </script> </head> <body onload="javascript: bookload(); checkIt();"> <form name="book"> <TABLE WIDTH="40%" CELLPADDING="0" CELLSPACING="0"> <TR VALIGN="TOP"> <TD VALIGN="TOP" ALIGN="left"><FONT SIZE="3"><B>Customer Name </B></FONT></TD> <TD VALIGN="TOP" ALIGN="LEFT"> <INPUT TYPE="TEXT" NAME="firstname" SIZE="10"> <INPUT TYPE="TEXT" NAME="surname" SIZE="25"></TD> </TR> <TR> <TD VALIGN="TOP" ALIGN="left"><FONT SIZE="3"><B>E-mail Address:</B></FONT></TD> <TD VALIGN="TOP" ALIGN="LEFT"> <INPUT TYPE="TEXT" NAME="email" SIZE="40"></TD> </TR> <TR VALIGN="TOP"> <TD VALIGN="TOP" ALIGN="left"><FONT SIZE="3"><b>Telephone:</b></FONT></TD> <Td VALIGN="TOP" ALIGN="left"> (<INPUT TYPE="TEXT" NAME="area" SIZE="8">) <INPUT TYPE="TEXT" NAME="telephone" SIZE="15"></Td> </TR> </table> <br><br><br> <table cellSpacing="1" cellPadding="3" width="95%" align="left" border="2"> <tr> </TR> <tr> <td><b>No of Passengers<b> </td> <TD VALIGN="MIDDLE" ALIGN="left"> <INPUT TYPE="TEXT" NAME="passa" SIZE="10"> </td> <td> </td> </tr> <tr> <td><b>Month Of Travel<b> </td> <td><select name="Month2"> <option selected><option>June<option>July</option></select></td> <td> </td> </tr> <TD VALIGN="MIDDLE" ALIGN="LEFT"><B>Berth</B></TD> <TD VALIGN="MIDDLE" ALIGN="left"> 2<INPUT TYPE="CHECKBOX" NAME="berth4" onClick=""><BR> 4<INPUT TYPE="CHECKBOX" NAME="berth6" ONCLICK=""><BR> <TD VALIGN="MIDDLE" ALIGN="right"> <INPUT TYPE="TEXT" NAME="total1" SIZE="10"></td> </tr> <tr> <TD VALIGN="MIDDLE" ALIGN="LEFT"><B>Cabin</B></td> <td> Inner<INPUT TYPE="CHECKBOX" NAME="Cabin1" onClick=""><BR> Outer<INPUT TYPE="CHECKBOX" NAME="Cabin2" ONCLICK=""><BR> </td> <TD VALIGN="MIDDLE" ALIGN="right"> <INPUT TYPE="TEXT" NAME="total2" SIZE="10"></td> </TR> <tr> <td><b> Total<b> </td> <td> </td> <TD VALIGN="MIDDLE" ALIGN="right"> <INPUT TYPE="TEXT" NAME="total3" SIZE="10"> </td> </tr> <tr> <td colspan="3"><input type="submit" value="submit" name="subbut" onSubmit="checkIt()" /></td> </tr> </table> </form> </body> </html>



Reply With Quote

Bookmarks