Something like this:-
Code:
<select id = "sel1" onchange = "assignPrices()">>
<option value="A">Product 1</option>
<option value="B">Product 2</option>
<option value="C">Product 3</option>
</select>
<script type = "text/javascript">
function assignPrices() {
var price = 0;
var now = new Date();
var mth = now.getMonth(); // note that in Javascript months are 0-11
var val = document.getElementById("sel1").value;
if (mth == 8) { // September
switch (val) {
case "A": price = 100; break;
case "B": price = 150; break;
case "C": price = 200; break;
}
}
if (mth == 9) { // October
switch (val) {
case "A": price = 50; break;
case "B": price = 100; break;
case "C": price = 150; break;
}
}
alert ("The price is " + price);
}
assignPrices();
</script>
Note that JavaScript form validation only provides convenience for users, not security. This means that JavaScript should be used as an "enhancement", not as a requirement. So your form should not be dependent on JavaScript alone to assign the prices or perform your validation. Instead, whatever server-side language you use to process the form (PERL, ASP, PHP, etc.) should also perform the same validation. Otherwise, people will be able to bypass your validation (and even possibly inject malicious code) simply by disabling JavaScript.
This free kick is going to be a left-footed or a right-footed strike. - Football commentator