473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to use option name as value using javascript?

4
Hello,

I came across this forum looking for an answer and by reading I found that it seemed really supportive forum. I hope I am posing to correct tread :-(

I need to use the option name as value to pass on as well as the value it self.

I have a select statement. Because I am using calculations for the freight for each state, in the Value I have the ($) amounts. This is required not only for final freight calculation depending on which state is selected but also I need to know which amount they have selected.

Unfortunately I am no expert in in java scripts. What I also need to show on my confirmation page is the actual name of the State. At the moment (understandable) not showing as options can't have two values.

Can anyone hand over a plate please ?

Seriously I do need some thing I can copy and paste to make it work. So far I have build the form my self...and here it is in case you want to peak http://www.photooncanvas.com.au/step-1.php



Expand|Select|Wrap|Line Numbers
  1. <span class="left">
  2.   <input id="suburb" name="suburb" type="text" class="field text addr" value="" tabindex="10"  />
  3.   <label for="suburb">City</label>
  4.   </span>
  5.  
  6.  
  7.   <span class="right">
  8.   <select name="freight_fee_($)" class="field select medium" id="freight_fee_($)"  tabindex="14" >
  9.     <option value="9">Queensland</option>
  10.     <option value="12">New South Wales</option>
  11.     <option value="12">ACT</option>
  12.     <option value="13">Victoria</option>
  13.     <option value="14">South Australia</option>
  14.     <option value="16">Western Australia</option>
  15.     <option value="15">Northern Territory</option>
  16.     <option value="15">Tasmania</option>
  17.   </select>
  18.  
  19.  
  20.  
  21.     <label for="canvas_size">State / Region</label>
  22.   </span>
and the calculation done at the bottom of the page like so -

Expand|Select|Wrap|Line Numbers
  1. <input name="button" type="button" id="button" onclick="KW_calcForm('Total',100,2,'(','#qty_480mmx350mm_ordered','*','#total_amount_for_ 480mmx350mm_ordered',')','+','(','#qty_480mmx480mm_ordered','*','#total_amount_for_ 480mmx480mm_ordered',')','+','(','#qty_780mmx480mm_ordered','*','#total_amount_for_ 780mmx480mm_ordered',')','+','#freight_fee_($)')" value="Total" /> 
  2.  
  3. <input id="saveForm" name="saveForm" class="btTxt submit" type="submit" value="Next" />
There is also some java script that does the calculation on the top of the page.




In my posted form I want to be able to request the name of the selected item (eg Queensland) and the value.

As you can see here is my confirmation page

------------------------------------------

Confirm Title: Photo On Canvas Order

Total Amount For 480mmx350mm Ordered:85
Qty 480mmx350mm Ordered: 1
Qty 480mmx480mm Ordered: 0
Qty 780mmx480mm Ordered: 0
First Name: test
Surname: me
Email: me@example.org
Address: My home address
Suburb: Bondi
State : << I also want to display the state they have chosen (eg Queensland) >>

Freight Fee ($): 12 >>>>> this is the value from the above option fields
Post Code: 2000
Total: 94.00
Attachment: ist2_4469423-business-card-or-white-sign.jpg
Jul 20 '10 #1
1 1576
acoder
16,027 Expert Mod 8TB
Since this is on the confirmation page, it's actually PHP code you should be looking at.

However, I can suggest 3 possible solutions:
1. Use JavaScript to set a hidden field to the state when an option is selected, but this depends on JavaScript to function.
2. Set the value of each option to something like "9|Queensland" which you can use to split on the confirmation page.
3. Probably the best idea would be to take the state name and use that to determine the freight fee on the server-side. If you depend on the value passed, someone could change 9 to 0 or something. Of course, you could still use JavaScript to give the user some idea of how much it would cost, but you don't depend on it.
Jul 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: chrispragash | last post by:
Hello All, This may be a silly question to ask - but for some reason I am unable to get this to work! I have a server control that renders a Label and a linkbutton, and I have a Javascript...
1
by: dvpandya | last post by:
Hi friends thanks in advance i want to check password field value after submiting the form by post method. How can i get that value in html page using javascirpt Example :
5
by: jose1lm | last post by:
What is supposed to happen: A user enters data into one of the FORM input selections. When the user submits the form, the onclick event is supposed to go to a function that will set another FORM...
4
by: =?Utf-8?B?Qw==?= | last post by:
How do I get the text from my cell e..g. <td>Test Text</td> var elTableCells = elTableRow.getElementsByTagName("td"); alert(elTableCells.innerText);
1
by: =?Utf-8?B?Qw==?= | last post by:
How do I get the text from my cell e..g. <td>Test Text</td> var elTableCells = elTableRow.getElementsByTagName("td"); alert(elTableCells.innerText);
1
by: sumanthdivvela | last post by:
<select name="cityName" class="CLiKSformfield" id="IdfbCity" onChange="javascript:addCity(this);"> <option value="ALL">Select Location</option> <option value="1001" >...
5
by: plsHelpMe | last post by:
Hi Frens, I want to show a blank space at the begining of the option tag using javascript, can anyone please help me for the same. Let me explain what i want: I want to have an event which the...
4
by: phpmagesh | last post by:
Hi I am using php and smarty, what i have to do is i have a drop down box with dynamic name, id and values. like <select name="id" id="id" onchange="sample()" > {foreach key=key_data...
1
by: jsaps33 | last post by:
Hi All, I'm wondering how I would change an initial value to a blank value if nothing gets entered into the text field. I have a form with multiple fields that visitors can enter data in to get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.