D
dysfunctional
Hello,
Hopefully some of you will be kind enough to help a Javascript zero like me
out.
I run a CGI-based hotel search online, which can be found at
http://www.triotours.com/faq/ma/hotel-search.htm
Part of the search is a piece of Javascript that someone wrote for me. It
does two things:
1. It sets the maximum rate ("max") that a visitor wants to search the
database with;
2. It sets which column in the database to search for that "max": either the
column "single_from" or the column "double_from".
The code of this Javascript:
function checkForm(f)
{ if ((!f.min.value)¦¦(!f.max.value)) {return true};
var roomtype;
for (i=0;i<f.elements.length;i++) {
e=f.elements;
if ((e.name=="rmtype")&&(e.checked)) {
roomtype=e.value;
}
}
if (roomtype=="Single") {
f.double_from.value="";
f.single_from.value="between "+f.min.value+" and "+f.max.value;
} else {
f.single_from.value="";
f.double_from.value="between "+f.min.value+" and "+f.max.value;
} return true;
}
One of the flaws of the form is that it requires "max" to be entered in
Moroccan dirham, which is obviously a currency that not many people are
familiar with.
So, I'd like to add a select list name="currency", the value of which would
then be used to calculate the input into dirhams.
<select name="currency">
<option value="1">Moroccan dirham</option>
<option value="9">US dollar</option>
<option value="11">Euro</option>
<option value="0.1">Japanese yen</option>
....etcetera
The value in the options is the conversion rate to Moroccan dirham. I chose
that because I thought it would be clever to work around a series of "var"
statements.
And that's where my knowledge of Javascript ends. I've played around with
document.getElementById and such, but I can't for the life of me find out
how I can get the value from "currency" into the Javascript code, so that it
does:
max = max * currency
If someone out there can, I'd be very grateful!
Jan
Hopefully some of you will be kind enough to help a Javascript zero like me
out.
I run a CGI-based hotel search online, which can be found at
http://www.triotours.com/faq/ma/hotel-search.htm
Part of the search is a piece of Javascript that someone wrote for me. It
does two things:
1. It sets the maximum rate ("max") that a visitor wants to search the
database with;
2. It sets which column in the database to search for that "max": either the
column "single_from" or the column "double_from".
The code of this Javascript:
function checkForm(f)
{ if ((!f.min.value)¦¦(!f.max.value)) {return true};
var roomtype;
for (i=0;i<f.elements.length;i++) {
e=f.elements;
if ((e.name=="rmtype")&&(e.checked)) {
roomtype=e.value;
}
}
if (roomtype=="Single") {
f.double_from.value="";
f.single_from.value="between "+f.min.value+" and "+f.max.value;
} else {
f.single_from.value="";
f.double_from.value="between "+f.min.value+" and "+f.max.value;
} return true;
}
One of the flaws of the form is that it requires "max" to be entered in
Moroccan dirham, which is obviously a currency that not many people are
familiar with.
So, I'd like to add a select list name="currency", the value of which would
then be used to calculate the input into dirhams.
<select name="currency">
<option value="1">Moroccan dirham</option>
<option value="9">US dollar</option>
<option value="11">Euro</option>
<option value="0.1">Japanese yen</option>
....etcetera
The value in the options is the conversion rate to Moroccan dirham. I chose
that because I thought it would be clever to work around a series of "var"
statements.
And that's where my knowledge of Javascript ends. I've played around with
document.getElementById and such, but I can't for the life of me find out
how I can get the value from "currency" into the Javascript code, so that it
does:
max = max * currency
If someone out there can, I'd be very grateful!
Jan