Web Hosting Talk







View Full Version : Help with drop downs.....


ThatScriptGuy
05-02-2006, 03:52 PM
OK, I've created a nice dynamically generated HTML/JS/PHP/MySQL form and it works fantastically! I have run into a bit of a problem, though....

The form can be found at

http://208.180.101.48/form.php

The products are all pulled from a database. I am using the prices as the value for the drop down boxes so that the javascript part of the form can be updated automatically. Now, however, the owner wants a submit button to take the user to a new page so that they can fill out another form and have the details emailed to the store. The problem with this is that I can't pass the product names through the form because the values of the drop downs are the prices.

In essence, my dilemma is that I don't know how to pass the product names from the first form to the second because the drop down values are prices, not names.....

One idea I had was to onClick have the <option> names assigned to hidden variables or an array using javascript. But I don't know how (if) that is possible.
If there is something I'm overlooking, please let me know.
Kevin

ThatScriptGuy
05-02-2006, 04:02 PM
AHA! Never mind...figured it out...

this.form.hidden1.value=this.options[ this.selectedIndex ].text;

orbitz
05-02-2006, 04:31 PM
thanks for posting the solution.
btw, I was taking a look at your page, and I must say that the orange color and those rows being so closed together make it hard for me to read.

ThatScriptGuy
05-02-2006, 05:09 PM
OH I know.....far from complete...just getting all these different aspects working together before I worry about anything else.....
Kevin

Christopher Lee
05-02-2006, 05:22 PM
I've only really skimmed the thread, but:

What happens if someone edits the HTML of your list and changes the price?

What happens if someone has Javascript disabled?

You might want to consider passing the key instead so you can always verify the values calculated by your script against rules on the server.

ThatScriptGuy
05-02-2006, 05:47 PM
No need for verification. This order form was started by a former employee, apparently, and i"m just continuing his work. Later, possibly...

As well, 100% of the users will be beginning PC users using Internet Explorer. The chances of having javascript disabled are very very slim. As well, the form will still work with javascript disabled....the only thing is that the price will not be updated automatically. Upon posting, we will have every product chosen along with its price.

As well, the form can only be submitted from the company server, so its not as if they can create a new HTMl page and post it to the PHP script....it simply wont allow it...
Kevin

Christopher Lee
05-02-2006, 09:06 PM
No need for verification. This order form was started by a former employee, apparently, and i"m just continuing his work. Later, possibly...

As well, 100% of the users will be beginning PC users using Internet Explorer. The chances of having javascript disabled are very very slim. As well, the form will still work with javascript disabled....the only thing is that the price will not be updated automatically. Upon posting, we will have every product chosen along with its price.

As well, the form can only be submitted from the company server, so its not as if they can create a new HTMl page and post it to the PHP script....it simply wont allow it...
Kevin

Even if it checks the refferer, refferers can be spoofed. Remember, HTTP is a stateless protocol. I may have requested the page from your server, but it is rendered on my PC in my cache.

On the other hand, if you are saying this is a kiosk program or an intranet application running on your machines, and is not available to the internet, then I can see your point.

ThatScriptGuy
05-02-2006, 09:08 PM
Mainly used for internal use. Certain users will be given access to it. IE: Not available to the public. If it were, I'd be a little more cautious.

Christopher Lee
05-02-2006, 09:09 PM
Mainly used for internal use. Certain users will be given access to it. IE: Not available to the public. If it were, I'd be a little more cautious.

Ah, then everything is cool. :)