Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 5th, 2004, 06:37 PM
Authorized User
 
Join Date: Nov 2003
Location: , , Australia.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting select option name not value

Hello,

i have a select statement
<select name ="cars">
  <option value ="1">Ford</option>
  <option value ="2">Holden</option>
  <option value ="3">Nissan</option>
</select>

In my javascript i want to be able to request the name of the selected item (eg Ford) not the value.

Any suggestions would be appreciated

Chris

  #2 (permalink)  
Old April 5th, 2004, 07:07 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

var text = document.getElementById('cars').options[document.getElementById('cars').selectedIndex].text;

:)

----------
---Snib---
----------

<><
  #3 (permalink)  
Old April 5th, 2004, 10:20 PM
Authorized User
 
Join Date: Nov 2003
Location: , , Australia.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Snib Exactly what i needed
Chris



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help putting xsl:value-of in select option eruditionist XSLT 2 September 25th, 2008 08:27 AM
wrap a select option nerssi HTML Code Clinic 0 June 16th, 2007 07:43 AM
option selected from a select box Adam H-W Classic ASP Basics 3 December 11th, 2006 11:09 AM
disable Select option Dj Kat HTML Code Clinic 2 March 10th, 2006 04:03 AM
Select/Option Problem TSEROOGY Javascript 2 October 4th, 2004 03:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.