Send maximum value to either of two database fields?

D

dysfunctional

Hi there,

I'm a complete zero at javascript in need of a hero. I run a free,
non-commercial site which includes a searchable database of hotels in
Morocco.

Find the page at http://www.triotours.com/faq/ma/hotel-search.htm

The form works fine, except for two essential functions:

1. Visitors enter the maximum amount of money they want to spend per night
("maxrate")
2. Visitors then enter whether the maximum amount is for a single or a
double room ("roomtype")

The CGI script would then search for a value between 1 and "maxrate" in the
field set by "roomtype", which could be either "single" or "double".

Can anyone of you help me with the code to do this? It would be much
appreciated!
 
K

kaeli

The CGI script would then search for a value between 1 and "maxrate" in the
field set by "roomtype", which could be either "single" or "double".

This is a javascript group.

What language is your CGI?
Try posting this at a group geared to that.

comp.lang.perl would be your best bet, I would guess, since you called it a
CGI script. :)

--
 
D

dysfunctional

OK, I can see what you mean. :)

But I was told I could use javascript to "assemble" the right info
client-side on the html page BEFORE sending it to the script.

Only thing is, I have no clue about javascript.
 
R

RobG

dysfunctional said:
OK, I can see what you mean. :)

But I was told I could use javascript to "assemble" the right info
client-side on the html page BEFORE sending it to the script.

Only thing is, I have no clue about javascript.

There is no point to 'assembling' the info on the client
machine. Just post the values back to your server and deal with
them there. Why make your page dependent on JavaScript
needlessly?

You have to validate the return values on the server anyway -
users may not have JavaScript enabled and the return may not
have actually come from your page - you have no idea how the
return values were generated or the intent of the person that
sent them.

Just consider if you have a script that creates a query for your
database on the client and you simply run it at the server with
out checking or validating anything. Anyone can create whatever
query they like and attempt to run it on your server.

So just let users pick reasonable values in your page and submit
them back to the sever. Perhaps you could offer rate ranges as
a set of radio buttons so users don't enter anything?
 
K

kaeli

OK, I can see what you mean. :)

But I was told I could use javascript to "assemble" the right info
client-side on the html page BEFORE sending it to the script.

Only thing is, I have no clue about javascript.

Javascript validation is best used in addition to any server-side validation,
as a courtesy to users who have it enabled so they don't have to wait for the
document to be sent to the server, rejected, and get the message back.

If you do it only with javascript, it's VERY hackable. ;)

If this isn't about validation, then I'm unclear on exactly what you're going
for. I don't see quite what you mean if you wanted javascript to do this:

"The CGI script would then search for a value between 1 and "maxrate" in the
field set by "roomtype", which could be either "single" or "double"."

I'm a bit database-centric in my application viewpoint, since I work with
them all the time. To me, it seems like that's a database search. Which JS
can't do. Am I misunderstanding what you want?

--
--
~kaeli~
Quantum Express: When you absolutely, positively, don't
know where it's going or when it needs to be there.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top