This is a discussion on "I need help with the Select Option....." within the JavaScript Forum section. This forum, and the thread "I need help with the Select Option..... are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
I need help with the Select Option.....
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
I need help with the Select Option.....
Ok, I am building a huge script. It is going to be for a customizeable pc page. They want it done in JavaScript so that is all good. What I don't know how to do is this. How do I set the Options on a select field equal to something. Then take what it is equal too and send it to be added. What I have come up with is a big mess. Once I get all the select fields turned into variables I am good. I can do all that, it's just getting these select fields read and sent to be added. If you would like to see the coding I have I will be more than glad to email it to you. Thanks again.
|
|
|
|
|||
|
When you say 'send to be added' are you sending the form values to a server-side script? Rather than email the code, posting the page to some temp place that we could look at it would make it easier for everyone to help.
|
|
|||
|
well I am not using any server side scripting for this. What I am doing is starting the script declaring all my variables. Then I add all of these variables up and display the sum on the bottom of the page. What I can't figure out is how I make the different Options in a drop down box equal a different value for that variable so that I can edit the form accordingly.
F.E.- If I had a drop down list with 3 different options: 20 gig HD - $50 40 gig HD - $100 60 gig HD - $150 Then.. I will have a variable called hardDrive for example. When I use the drop down box to select a 60 gig Hard drive, I want that option to change the variable to "150". That way, when you add the total price you get what you are looking for. I hope this helps you understand it better. I know I have to add a submit button... |
|
|||
|
with a SELECT you can set values for each option other than what's displayed:
on the SELECT use the onChange event to call the function that adds the different prices up, that way it'll update the price every time they change an option without having to hit a submit button. Instead of using variables for each price just use the value of the currently selected option of that SELECT, like if you've got SELECT NAME="hardDrive" you'd get the current value with:
|
|
|||
|
I am sorry.. Let me post this code and if you can edit it showing me how to use the onChange and the Others I would appreciate it. I am very new to Javascript. Thanks a bunch. Ohh, and I don't need one made for memory stick, I can make all the others myself if someone can show me how to use what Catalyst said.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> var hardDrive = 100; var memoryStick = 200; add = hardDrive + memoryStick; document.write("$" + add); </SCRIPT> <SELECT NAME="hardDrive"> <OPTION VALUE="200">20 gig Hard Drive</OPTION> <OPTION VALUE="300">40 gig Hard Drive</OPTION> <OPTION VALUE="400">60 gig Hard Drive</OPTION> <OPTION VALUE="500">80 gig Hard Drive</OPTION> </SELECT> </BODY> </HTML> |
|
|||
|
This will give you an idea. BTW, the innerHTML bit is not Opera/NS compatible, I put it together just for the example.
u2o |
![]() |
| Tags |
| help, select, option |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| chained select box dependable select | thenamenoonehastaken | JavaScript Forum | 0 | Feb 8th, 2008 05:49 |
| Option values | AdINo | Web Page Design | 3 | Jul 6th, 2007 10:09 |
| Option values | AdINo | JavaScript Forum | 2 | Jul 5th, 2007 18:48 |
| How to put bookmark option in my website | lekha | Starting Out | 1 | May 12th, 2007 11:47 |
| Drop Down Default Option | kal | PHP Forum | 2 | Feb 13th, 2006 07:43 |