Stucked with form elements - HELP PLEASE !

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
rax369
Forum Commoner
Posts: 56
Joined: Sun Oct 06, 2002 8:50 pm

Stucked with form elements - HELP PLEASE !

Post by rax369 »

Hi! I'm try to make a simple application, using MySQL and PHP.

To show u my idea, the image:

Image

Let me explain u now what I wanna achieve w/this. This is suppoustly a request product page, where a customer choose what product ask to some company X by chosing him/her it using the combo box (or list/menu).

Now, I'm stucked 'cause I dont know if what I wanna do is possible or not.

Let me explain u this pretty clear so that u get the idea:

In the picture above I pointed (w/red arrows) the 3 fields in my form, w/their respective form element names (prod_name for the combo box and prod_price and prod_qty for the text fields). What I wanna do is once a product is chosen from the combo box the price of the product, appears inmediately in the text box "prod_price" (located at the right side of the product), of course the price would be taken from a MySQL Database as well as is been taken by the combo box to show the product name.

It is possible to use the variables of one form, before they have been submited???? :?: :( basically, I'm stucked because I dont know if is possible to do that. I dont know how to show the price of the product at its right side inmediately since I dont know what product the customer chose. If I'd know that I could show it in the text field by usign a SQL query right ?

Thx in advance for any suggestion. :D
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

Well, this is the quick and dirty ... you'd query the database for all possible prices which can be displayed from the form and store those in a javascript code within your html source ... then you use javascript to automatically show the price in a text field when a drop-down menu is clicked

that's really the only way to do it
User avatar
rax369
Forum Commoner
Posts: 56
Joined: Sun Oct 06, 2002 8:50 pm

Post by rax369 »

oh man!, I dont know nothing of javascript, I'm just begining to learn a little of php. There isnt other way to do this really ????

'cause if not... mmm... I'm gonna continue stucked in this, or I better think in some other way to do this.

... suggestions are welcome!

thx guys :cry:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

until something is submitted your server-side php script knows nothing about the client-side document. You could disconnect from the network, reconnect and php wouldn't notice the difference (maybe except the remote-ip ;) )
User avatar
rax369
Forum Commoner
Posts: 56
Joined: Sun Oct 06, 2002 8:50 pm

Post by rax369 »

protokol wrote:Well, this is the quick and dirty ... you'd query the database for all possible prices which can be displayed from the form and store those in a javascript code within your html source ... then you use javascript to automatically show the price in a text field when a drop-down menu is clicked

that's really the only way to do it
something that comes to my mind if I do what u said protokol, is that that way to do it, would be very insecure I guess, 'cause doing that I'd be showing all the posible prices in my code to possible 'hackers' wishing to alter the page by changing the prices, I guess that way would be very insecure to do this, dont u agree w/me ? :D
Post Reply