Menu
Plz i need your help in Java Script reservation form:
1) How to change the text on the Java Script alert window.
2) How to make the terms & conditions check box is required to submit form.
3) When form is filled how to make a window shows that the bookings has been submit.
Thank you so much for the great assistance you provide ?
Rehab (Ms.)
From Cairo – Egypt
<i>
</i><script language="javascript">
function calculate(form)
{
var dbl = form.dbl.value;
var t_dbl = form.t_dbl.value;
var tpl = form.tpl.value;
var t_tpl = form.t_tpl.value;
var sgl = form.sgl.value;
var t_sgl = form.t_sgl.value;
var chd = form.chd.value;
var t_chd = form.t_chd.value;
var inf = form.inf.value;
var t_inf = form.t_inf.value;
var grand_total = form.grand_total.value;
form.t_dbl.value = (parseInt(dbl) * 1390);
form.t_tpl.value = (parseInt(tpl) * 2085);
form.t_sgl.value = (parseInt(sgl) * 945);
form.t_chd.value = (parseInt(chd) * 350);
form.t_inf.value = (parseInt(inf) * 250);
form.grand_total.value = (parseInt(form.t_dbl.value) +
parseInt(form.t_tpl.value) + parseInt(form.t_sgl.value) + parseInt(form.t_chd.value)+ parseInt(form.t_inf.value));
}
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.n'; }
} if (errors) alert('The following error(s) occurred:n'+errors);
document.MM_returnValue = (errors == '');
} }
</script>
[code=html]
<form name="form1" method="post" action="">
<table width="600">
<tr>
<td colspan="2" >* Title:</td>
<td colspan="2" ><select name="select" id="select">
<option selected>Dr.</option>
<option>Mr.</option>
<option>Mrs.</option>
<option>Ms.</option>
</select></td>
</tr>
<tr>
<td colspan="2">* Family Name:</td>
<td colspan="2"><input name="family name" type="text" id="family name"></td>
</tr>
<tr>
<td colspan="2">* First Name:</td>
<td colspan="2"><input name="First Name" type="text" id="first name"></td>
</tr>
<tr>
<td colspan="2">* E-mail:</td>
<td colspan="2"><input name="email" type="text" id="email" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" size="25"></td>
</tr>
<tr>
<td colspan="2"><label for="select2">* No of adults: </label></td>
<td colspan="2"><select name="select2" id="select2">
<option selected>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr>
<td colspan="2"><label for="select3">* No of children: </label></td>
<td colspan="2"><select name="select3" id="select3">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr>
<td colspan="2">* No of infant:</td>
<td colspan="2"><select name="select4" class="bg2" id="select6">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr >
<td><label for="select7"></label>
<select name="dbl" id="dbl" onChange="calculate(this.form)" >
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Double room $ 695 X 02 persons: $ 1390</td>
<td ><input name="t_dbl" type="text" id="t_dbl" value="0" size="10" readonly></td>
</tr>
<tr align="right">
<td> <select name="tpl" onChange="calculate(this.form)" id="tpl">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Triple room $ 695 X 03 persons: $ 2085</td>
<td ><input name="t_tpl" type="text" id="t_tpl" value="0" size="10" readonly></td>
</tr>
<tr>
<td ><select name="sgl" onChange="calculate(this.form)" id="sgl">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Single room $ 945 X 01 person: $ 945</td>
<td><input name="t_sgl" type="text" id="t_sgl" value="0" size="10" readonly></td>
</tr>
<tr>
<td><select name="chd" onChange="calculate(this.form)" id="chd">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Child $ 350 X 01 child: $ 350</td>
<td><input name="t_chd" type="text" id="t_chd" value="0" size="10" readonly></td>
</tr>
<tr>
<td><select name="inf" onChange="calculate(this.form)" id="inf">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Infant $ 250 X 01 infant:$ 250</td>
<td ><input name="t_inf" type="text" class="bg3" id="t_inf" value="0" size="10" readonly>
<label for="textfield5"></label></td>
</tr>
<tr>
<td>*</td>
<td colspan="2">*</td>
<td align="center">*</td>
</tr>
<tr >
<td><input name="grand_total" type="text" id="grand_total" value="0" size="10" readonly></td>
</tr>
<tr>
<td><input type="checkbox" name="I have read and accept the Terms & Conditions." id="I have read and accept the Tems & Conditions.">
<label for="I have read and accept the Terms & Conditions.">I have read and accept the Terms & Conditions.</label></td>
</tr>
<tr >
<td colspan="3"><input name="Submit" type="submit" id="Submit" value="Submit"></td>
<td><input type="Reset" name="Reset" id="Reset" value="Reset"></td>
</tr>
</table>
</form>
[/code]
Hope this is clear and there is possibility to help me.
0.1.9 — BETA 5.19