Page 1 of 1

Stucked with form elements - HELP PLEASE !

Posted: Sun Oct 20, 2002 10:07 pm
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

Posted: Sun Oct 20, 2002 10:49 pm
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

Posted: Mon Oct 21, 2002 12:12 am
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:

Posted: Mon Oct 21, 2002 12:16 am
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 ;) )

Posted: Mon Oct 21, 2002 2:55 pm
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