473,320 Members | 1,865 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,320 software developers and data experts.

question about select in forms

Hello, lets say i have a select like this:
<select name="numbers" id="numbers">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>

Lets say a user selects "Two" from the drop down menu... now I want to
get that "Two" into a variable... but not "2" because i can get 2 by
using numbers.value..... but how could i get the "Two" into a variable?

Dec 16 '06 #1
2 1107
ASM
Ken1 a écrit :
Hello, lets say i have a select like this:
<select name="numbers" id="numbers">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>

Lets say a user selects "Two" from the drop down menu... now I want to
get that "Two" into a variable... but not "2" because i can get 2 by
using numbers.value..... but how could i get the "Two" into a variable?
var o = document.forms['myForm'].elements['numbers'].options
myVariable = o[o.selectedIndex].text;

o = document.myForm.numbers.options;
o = document.forms[0].numbers.options;

<select name="numbers" id="numbers"
onchange="var k = this.selectedIndex;
myVariable = this.options[k].text;
">

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 16 '06 #2
thanks! ill try this out.

ASM wrote:
Ken1 a écrit :
Hello, lets say i have a select like this:
<select name="numbers" id="numbers">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>

Lets say a user selects "Two" from the drop down menu... now I want to
get that "Two" into a variable... but not "2" because i can get 2 by
using numbers.value..... but how could i get the "Two" into a variable?

var o = document.forms['myForm'].elements['numbers'].options
myVariable = o[o.selectedIndex].text;

o = document.myForm.numbers.options;
o = document.forms[0].numbers.options;

<select name="numbers" id="numbers"
onchange="var k = this.selectedIndex;
myVariable = this.options[k].text;
">

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) ...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
14
by: deko | last post by:
For some reason this does not seem to be working... Am I missing something basic? Dim rst As DAO.Recordset Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("qryEmailS") '...
6
by: Noozer | last post by:
I'm developing a database using MS Access and have come across a problem. The majority of my database is pretty straightforward "many to one" relationships. I have one relationship that is...
6
by: Jim M | last post by:
I've been distributing a fairly mature, very specific MS Access application to end users in small offices of colleges for several years now. This is a part-time venture and low volume operation-...
1
by: Flack | last post by:
Hey guys, I'm having some weird issues when calling Dispose on one of the controls in a user control from an asycn or sync method. When called form an async method Dispose makes a call to...
3
by: Alan | last post by:
I'm having brain fade today... Can the recordsource in a Form's properties do more than one select statement based on criteria? On a popup subform I'm trying to display matching records from a...
7
by: Brave | last post by:
I have two questions about pulldown menus on forms. 1: Can I have the options of one pulldown menu be dictated by the choice from another pulldown menu (example beow)? 2: Can I have a form be...
4
by: shane | last post by:
I am trying to get values from a WMI Query in my textbox, txtResults I don't think I am understand what I need to do to move the value from the for each statement in the quary into the textbox, as...
3
by: Italio Novuas | last post by:
Hi all, let me begin by saying that I *ALMOST* have this complete! What I'm trying to do is make it so my text area shows the innerHTML of any select item with the same value. For example, if I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.