My client is a complete novice when it comes to web technology, so Im trying to validate as much as possible with this form (using javascript) before it gets submitted in the database.
I have two problems on hand:
1) I am trying to validate it so that the value for Volume5a is equal to the the last volume that has been selected.
This means that value for Volume5a may equal to Volume4b or Volume3b or Volume2b or Volume1b. The problem is the client may use up to 5 different volumes, but he doesnt have to. So he can use 4 or 3 or 2 different volumes if he wishes to – depending on his products and their volume prices.
2) The volumes quantities must be correct. So if volume 1 and 2 were selected, Volume2a must equal to Volume1b + 1. If volume 2 and 3 were selected, Volume3a must equal to Volume2b + 1….. and so forth.
Again, not all 5 volumes have to be used.
Heres my form! (or alternatively: [url]http://members.iinet.net.au/~hinda/js/form.htm
function validateform(){
var aSetPrice = document.form1.SetPrice.value;
var SPT = document.form1.SetorVolumePrice;
var V5 = document.form1.VolumeTick5;
var V4 = document.form1.VolumeTick4;
var V3 = document.form1.VolumeTick3;
var V2 = document.form1.VolumeTick2;
var V1 = document.form1.VolumeTick1;
var V1Qa = document.form1.Volume1a.value
var V1Qb = document.form1.Volume1b.value
var VP1 = document.form1.VolumePrice1.value
var V2Qa = document.form1.Volume2a.value
var V2Qb = document.form1.Volume2b.value
var VP2 = document.form1.VolumePrice2.value
var V3Qa = document.form1.Volume3a.value
var V3Qb = document.form1.Volume3b.value
var VP3 = document.form1.VolumePrice3.value
var V4Qa = document.form1.Volume4a.value
var V4Qb = document.form1.Volume4b.value
var VP4 = document.form1.VolumePrice4.value
var V5Qa = document.form1.Volume5a.value
var VP5 = document.form1.VolumePrice5.value
</script>
</head>
<body>
<p><form name=”form1″ method=”post” onSubmit=”return validateform()” action=”addproduct.asp”>
<input type=”radio” value=”V1″ name=”SetorVolumePrice” checked>Set Price: $
<input type=”text” name=”SetPrice” size=”5″><p>
<input type=”radio” value=”V2″ name=”SetorVolumePrice”>Volume Price<br>
<input type=”checkbox” name=”VolumeTick1″ value=”ON”>Volume
1: Quantity
<input type=”text” name=”Volume1a” size=”1″> to
<input type=”text” name=”Volume1b” size=”1″> = Unit Price: $<input type=”text” name=”VolumePrice1″ size=”4″><br>
<input type=”checkbox” name=”VolumeTick2″ value=”ON”>Volume
2: Quantity
<input type=”text” name=”Volume2a” size=”1″> to
<input type=”text” name=”Volume2b” size=”1″> = Unit Price: $<input type=”text” name=”VolumePrice2″ size=”4″><br>
<input type=”checkbox” name=”VolumeTick3″ value=”ON”>Volume
3: Quantity
<input type=”text” name=”Volume3a” size=”1″> to
<input type=”text” name=”Volume3b” size=”1″> = Unit Price: $<input type=”text” name=”VolumePrice3″ size=”4″><br>
<input type=”checkbox” name=”VolumeTick4″ value=”ON”>Volume
4: Quantity
<input type=”text” name=”Volume4a” size=”1″> to
<input type=”text” name=”Volume4b” size=”1″> = Unit Price: $<input type=”text” name=”VolumePrice4″ size=”4″><br>
<input type=”checkbox” name=”VolumeTick5″ value=”ON”>Volume
5: Quantity
<input type=”text” name=”Volume5a” size=”1″>+ = Unit Price: $<input type=”text” name=”VolumePrice5″ size=”4″><input type=”submit” value=”Submit” name=”B1″ style=”float: right”></p>
<p>
</p>
<p>
</p>
</form>
</body>
</html>